mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-12-11 11:41:33 +02:00
Bug fix: Consider target_lsn during validate WAL
This commit is contained in:
parent
7d53afb1c7
commit
723c2b01a2
@ -519,6 +519,7 @@ validate_wal(pgBackup *backup, const char *archivedir,
|
|||||||
TimestampTz last_time = 0;
|
TimestampTz last_time = 0;
|
||||||
char last_timestamp[100],
|
char last_timestamp[100],
|
||||||
target_timestamp[100];
|
target_timestamp[100];
|
||||||
|
XLogRecPtr last_lsn = InvalidXLogRecPtr;
|
||||||
bool all_wal = false;
|
bool all_wal = false;
|
||||||
char backup_xlog_path[MAXPGPATH];
|
char backup_xlog_path[MAXPGPATH];
|
||||||
|
|
||||||
@ -585,6 +586,7 @@ validate_wal(pgBackup *backup, const char *archivedir,
|
|||||||
/* We can restore at least up to the backup end */
|
/* We can restore at least up to the backup end */
|
||||||
time2iso(last_timestamp, lengthof(last_timestamp), backup->recovery_time);
|
time2iso(last_timestamp, lengthof(last_timestamp), backup->recovery_time);
|
||||||
last_xid = backup->recovery_xid;
|
last_xid = backup->recovery_xid;
|
||||||
|
last_lsn = backup->stop_lsn;
|
||||||
|
|
||||||
if ((TransactionIdIsValid(target_xid) && target_xid == last_xid)
|
if ((TransactionIdIsValid(target_xid) && target_xid == last_xid)
|
||||||
|| (target_time != 0 && backup->recovery_time >= target_time)
|
|| (target_time != 0 && backup->recovery_time >= target_time)
|
||||||
@ -608,6 +610,7 @@ validate_wal(pgBackup *backup, const char *archivedir,
|
|||||||
timestamp_record = getRecordTimestamp(xlogreader, &last_time);
|
timestamp_record = getRecordTimestamp(xlogreader, &last_time);
|
||||||
if (XLogRecGetXid(xlogreader) != InvalidTransactionId)
|
if (XLogRecGetXid(xlogreader) != InvalidTransactionId)
|
||||||
last_xid = XLogRecGetXid(xlogreader);
|
last_xid = XLogRecGetXid(xlogreader);
|
||||||
|
last_lsn = xlogreader->ReadRecPtr;
|
||||||
|
|
||||||
/* Check target xid */
|
/* Check target xid */
|
||||||
if (TransactionIdIsValid(target_xid) && target_xid == last_xid)
|
if (TransactionIdIsValid(target_xid) && target_xid == last_xid)
|
||||||
@ -616,12 +619,19 @@ validate_wal(pgBackup *backup, const char *archivedir,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Check target time */
|
/* Check target time */
|
||||||
else if (target_time != 0 && timestamp_record && timestamptz_to_time_t(last_time) >= target_time)
|
else if (target_time != 0 && timestamp_record &&
|
||||||
|
timestamptz_to_time_t(last_time) >= target_time)
|
||||||
{
|
{
|
||||||
all_wal = true;
|
all_wal = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* If there are no target xid and target time */
|
/* Check target lsn */
|
||||||
|
else if (XRecOffIsValid(target_xid) && last_lsn >= target_lsn)
|
||||||
|
{
|
||||||
|
all_wal = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* If there are no target xid, target time and target lsn */
|
||||||
else if (!TransactionIdIsValid(target_xid) && target_time == 0 &&
|
else if (!TransactionIdIsValid(target_xid) && target_time == 0 &&
|
||||||
xlogreader->ReadRecPtr == backup->stop_lsn)
|
xlogreader->ReadRecPtr == backup->stop_lsn)
|
||||||
{
|
{
|
||||||
@ -638,15 +648,17 @@ validate_wal(pgBackup *backup, const char *archivedir,
|
|||||||
|
|
||||||
/* There are all needed WAL records */
|
/* There are all needed WAL records */
|
||||||
if (all_wal)
|
if (all_wal)
|
||||||
elog(INFO, "backup validation completed successfully on time %s and xid " XID_FMT,
|
elog(INFO, "backup validation completed successfully on time %s, xid " XID_FMT " and LSN %X/%X",
|
||||||
last_timestamp, last_xid);
|
last_timestamp, last_xid,
|
||||||
|
(uint32) (last_lsn >> 32), (uint32) last_lsn);
|
||||||
/* Some needed WAL records are absent */
|
/* Some needed WAL records are absent */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PrintXLogCorruptionMsg(&private, WARNING);
|
PrintXLogCorruptionMsg(&private, WARNING);
|
||||||
|
|
||||||
elog(WARNING, "recovery can be done up to time %s and xid " XID_FMT,
|
elog(WARNING, "recovery can be done up to time %s, xid " XID_FMT " and LSN %X/%X",
|
||||||
last_timestamp, last_xid);
|
last_timestamp, last_xid,
|
||||||
|
(uint32) (last_lsn >> 32), (uint32) last_lsn);
|
||||||
|
|
||||||
if (target_time > 0)
|
if (target_time > 0)
|
||||||
time2iso(target_timestamp, lengthof(target_timestamp),
|
time2iso(target_timestamp, lengthof(target_timestamp),
|
||||||
|
@ -69,10 +69,10 @@ bool smooth_checkpoint;
|
|||||||
bool is_remote_backup = false;
|
bool is_remote_backup = false;
|
||||||
|
|
||||||
/* restore options */
|
/* restore options */
|
||||||
static char *target_time;
|
static char *target_time = NULL;
|
||||||
static char *target_xid;
|
static char *target_xid = NULL;
|
||||||
static char *target_lsn;
|
static char *target_lsn = NULL;
|
||||||
static char *target_inclusive;
|
static char *target_inclusive = NULL;
|
||||||
static TimeLineID target_tli;
|
static TimeLineID target_tli;
|
||||||
static bool target_immediate;
|
static bool target_immediate;
|
||||||
static char *target_name = NULL;
|
static char *target_name = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user