mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-20 11:34:51 +02:00
If WAL segment is lost or broken, update status of the corresponding backup to CORRUPT
This commit is contained in:
parent
0f212e0455
commit
8c74cf7cb3
11
parsexlog.c
11
parsexlog.c
@ -155,6 +155,7 @@ extractPageMap(const char *archivedir, XLogRecPtr startpoint, TimeLineID tli,
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO Add comment, review */
|
||||
void
|
||||
validate_wal(pgBackup *backup,
|
||||
const char *archivedir,
|
||||
@ -245,6 +246,10 @@ validate_wal(pgBackup *backup,
|
||||
{
|
||||
if (xlogfpath[0] != 0)
|
||||
{
|
||||
/* Update backup status */
|
||||
backup->status = BACKUP_STATUS_CORRUPT;
|
||||
pgBackupWriteBackupControlFile(backup);
|
||||
|
||||
/* XLOG reader couldnt read WAL segment */
|
||||
if (!xlogexists)
|
||||
elog(WARNING, "WAL segment \"%s\" is absent", xlogfpath);
|
||||
@ -254,11 +259,17 @@ validate_wal(pgBackup *backup,
|
||||
}
|
||||
|
||||
if (!got_endpoint)
|
||||
{
|
||||
/* Update backup status */
|
||||
backup->status = BACKUP_STATUS_CORRUPT;
|
||||
pgBackupWriteBackupControlFile(backup);
|
||||
|
||||
elog(ERROR, "there are not enough WAL records to restore from %X/%X to %X/%X",
|
||||
(uint32) (backup->start_lsn >> 32),
|
||||
(uint32) (backup->start_lsn),
|
||||
(uint32) (backup->stop_lsn >> 32),
|
||||
(uint32) (backup->stop_lsn));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target_time > 0)
|
||||
|
38
restore.c
38
restore.c
@ -122,7 +122,7 @@ do_restore_or_validate(time_t target_backup_id,
|
||||
timelines = readTimeLineHistory_probackup(target_tli);
|
||||
}
|
||||
|
||||
/* Find backup range we should restore. */
|
||||
/* Find backup range we should restore or validate. */
|
||||
for (i = 0; i < parray_num(backups); i++)
|
||||
{
|
||||
current_backup = (pgBackup *) parray_get(backups, i);
|
||||
@ -217,40 +217,42 @@ do_restore_or_validate(time_t target_backup_id,
|
||||
pgBackupValidate(backup);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate corresponding WAL files.
|
||||
* TODO Shouldn't we pass recovery_target_timeline as last argument?
|
||||
*/
|
||||
validate_wal(dest_backup, arclog_path, rt->recovery_target_time,
|
||||
rt->recovery_target_xid, base_full_backup->tli);
|
||||
|
||||
|
||||
/* We ensured that all backups are valid, now restore if required */
|
||||
if (is_restore)
|
||||
{
|
||||
pgBackup *backup;
|
||||
for (i = base_full_backup_index; i >= dest_backup_index; i--)
|
||||
{
|
||||
pgBackup *backup = (pgBackup *) parray_get(backups, i);
|
||||
backup = (pgBackup *) parray_get(backups, i);
|
||||
if (backup->status == BACKUP_STATUS_OK)
|
||||
restore_backup(backup);
|
||||
else
|
||||
elog(ERROR, "backup %s is not valid",
|
||||
base36enc(backup->start_time));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete files which are not in dest backup file list. Files which were
|
||||
* deleted between previous and current backup are not in the list.
|
||||
*/
|
||||
if (is_restore)
|
||||
{
|
||||
pgBackup *dest_backup = (pgBackup *) parray_get(backups, dest_backup_index);
|
||||
/*
|
||||
* Delete files which are not in dest backup file list. Files which were
|
||||
* deleted between previous and current backup are not in the list.
|
||||
*/
|
||||
if (dest_backup->backup_mode != BACKUP_MODE_FULL)
|
||||
remove_deleted_files(dest_backup);
|
||||
}
|
||||
|
||||
if (!dest_backup->stream
|
||||
|| (target_time != NULL || target_xid != NULL))
|
||||
{
|
||||
if (is_restore)
|
||||
/* TODO Add comment */
|
||||
if (!dest_backup->stream
|
||||
|| (target_time != NULL || target_xid != NULL))
|
||||
{
|
||||
create_recovery_conf(target_backup_id, target_time, target_xid,
|
||||
target_inclusive, target_tli);
|
||||
else
|
||||
validate_wal(dest_backup, arclog_path, rt->recovery_target_time,
|
||||
rt->recovery_target_xid, base_full_backup->tli);
|
||||
}
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
|
Loading…
x
Reference in New Issue
Block a user