mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-02-03 14:01:57 +02:00
Bug fix: Get restore_lsn from pg_create_restore_point result
This commit is contained in:
parent
b4e0eaef3e
commit
a8b5e540d4
44
src/backup.c
44
src/backup.c
@ -1071,8 +1071,8 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
|
||||
{
|
||||
PGresult *res;
|
||||
const char *params[2];
|
||||
uint32 xlogid;
|
||||
uint32 xrecoff;
|
||||
uint32 lsn_hi;
|
||||
uint32 lsn_lo;
|
||||
PGconn *conn;
|
||||
|
||||
params[0] = label;
|
||||
@ -1100,9 +1100,9 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
|
||||
backup_in_progress = true;
|
||||
|
||||
/* Extract timeline and LSN from results of pg_start_backup() */
|
||||
XLogDataFromLSN(PQgetvalue(res, 0, 0), &xlogid, &xrecoff);
|
||||
XLogDataFromLSN(PQgetvalue(res, 0, 0), &lsn_hi, &lsn_lo);
|
||||
/* Calculate LSN */
|
||||
backup->start_lsn = (XLogRecPtr) ((uint64) xlogid << 32) | xrecoff;
|
||||
backup->start_lsn = ((uint64) lsn_hi )<< 32 | lsn_lo;
|
||||
|
||||
PQclear(res);
|
||||
|
||||
@ -1585,8 +1585,8 @@ wait_replica_wal_lsn(XLogRecPtr lsn, bool is_start_backup)
|
||||
while (true)
|
||||
{
|
||||
PGresult *res;
|
||||
uint32 xlogid;
|
||||
uint32 xrecoff;
|
||||
uint32 lsn_hi;
|
||||
uint32 lsn_lo;
|
||||
XLogRecPtr replica_lsn;
|
||||
|
||||
/*
|
||||
@ -1617,9 +1617,9 @@ wait_replica_wal_lsn(XLogRecPtr lsn, bool is_start_backup)
|
||||
}
|
||||
|
||||
/* Extract timeline and LSN from result */
|
||||
XLogDataFromLSN(PQgetvalue(res, 0, 0), &xlogid, &xrecoff);
|
||||
XLogDataFromLSN(PQgetvalue(res, 0, 0), &lsn_hi, &lsn_lo);
|
||||
/* Calculate LSN */
|
||||
replica_lsn = (XLogRecPtr) ((uint64) xlogid << 32) | xrecoff;
|
||||
replica_lsn = ((uint64) lsn_hi) << 32 | lsn_lo;
|
||||
PQclear(res);
|
||||
|
||||
/* target lsn was replicated */
|
||||
@ -1653,8 +1653,8 @@ pg_stop_backup(pgBackup *backup)
|
||||
PGconn *conn;
|
||||
PGresult *res;
|
||||
PGresult *tablespace_map_content = NULL;
|
||||
uint32 xlogid;
|
||||
uint32 xrecoff;
|
||||
uint32 lsn_hi;
|
||||
uint32 lsn_lo;
|
||||
XLogRecPtr restore_lsn = InvalidXLogRecPtr;
|
||||
int pg_stop_backup_timeout = 0;
|
||||
char path[MAXPGPATH];
|
||||
@ -1699,6 +1699,10 @@ pg_stop_backup(pgBackup *backup)
|
||||
|
||||
res = pgut_execute(conn, "SELECT pg_catalog.pg_create_restore_point($1)",
|
||||
1, params);
|
||||
/* Extract timeline and LSN from the result */
|
||||
XLogDataFromLSN(PQgetvalue(res, 0, 0), &lsn_hi, &lsn_lo);
|
||||
/* Calculate LSN */
|
||||
restore_lsn = ((uint64) lsn_hi) << 32 | lsn_lo;
|
||||
PQclear(res);
|
||||
}
|
||||
|
||||
@ -1731,7 +1735,6 @@ pg_stop_backup(pgBackup *backup)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
stop_backup_query = "SELECT"
|
||||
" pg_catalog.txid_snapshot_xmax(pg_catalog.txid_current_snapshot()),"
|
||||
" current_timestamp(0)::timestamptz,"
|
||||
@ -1750,6 +1753,8 @@ pg_stop_backup(pgBackup *backup)
|
||||
*/
|
||||
if (pg_stop_backup_is_sent && !in_cleanup)
|
||||
{
|
||||
res = NULL;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (!PQconsumeInput(conn) || PQisBusy(conn))
|
||||
@ -1791,8 +1796,11 @@ pg_stop_backup(pgBackup *backup)
|
||||
{
|
||||
switch (PQresultStatus(res))
|
||||
{
|
||||
/*
|
||||
* We should expect only PGRES_TUPLES_OK since pg_stop_backup
|
||||
* returns tuples.
|
||||
*/
|
||||
case PGRES_TUPLES_OK:
|
||||
case PGRES_COMMAND_OK:
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "query failed: %s query was: %s",
|
||||
@ -1804,9 +1812,9 @@ pg_stop_backup(pgBackup *backup)
|
||||
backup_in_progress = false;
|
||||
|
||||
/* Extract timeline and LSN from results of pg_stop_backup() */
|
||||
XLogDataFromLSN(PQgetvalue(res, 0, 2), &xlogid, &xrecoff);
|
||||
XLogDataFromLSN(PQgetvalue(res, 0, 2), &lsn_hi, &lsn_lo);
|
||||
/* Calculate LSN */
|
||||
stop_backup_lsn = (XLogRecPtr) ((uint64) xlogid << 32) | xrecoff;
|
||||
stop_backup_lsn = ((uint64) lsn_hi) << 32 | lsn_lo;
|
||||
|
||||
if (!XRecOffIsValid(stop_backup_lsn))
|
||||
{
|
||||
@ -2617,16 +2625,16 @@ get_last_ptrack_lsn(void)
|
||||
|
||||
{
|
||||
PGresult *res;
|
||||
uint32 xlogid;
|
||||
uint32 xrecoff;
|
||||
uint32 lsn_hi;
|
||||
uint32 lsn_lo;
|
||||
XLogRecPtr lsn;
|
||||
|
||||
res = pgut_execute(backup_conn, "select pg_catalog.pg_ptrack_control_lsn()", 0, NULL);
|
||||
|
||||
/* Extract timeline and LSN from results of pg_start_backup() */
|
||||
XLogDataFromLSN(PQgetvalue(res, 0, 0), &xlogid, &xrecoff);
|
||||
XLogDataFromLSN(PQgetvalue(res, 0, 0), &lsn_hi, &lsn_lo);
|
||||
/* Calculate LSN */
|
||||
lsn = (XLogRecPtr) ((uint64) xlogid << 32) | xrecoff;
|
||||
lsn = ((uint64) lsn_hi) << 32 | lsn_lo;
|
||||
|
||||
PQclear(res);
|
||||
return lsn;
|
||||
|
Loading…
x
Reference in New Issue
Block a user