Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2fdd73

Browse files
committed
[Issue #65] Improvement of merge crash safety, previously FULL backup would gain OK status before changing of start_time. If crash happens here, then in rare case of FULL backup having multiple children it could lead to data corruption when restoring one of such children
1 parent 1b0eb68 commit b2fdd73

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/merge.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,9 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
328328

329329
/*
330330
* Update to_backup metadata.
331+
* We cannot set backup status to OK just yet,
332+
* because it still has old start_time.
331333
*/
332-
to_backup->status = BACKUP_STATUS_OK;
333334
StrNCpy(to_backup->program_version, PROGRAM_VERSION,
334335
sizeof(to_backup->program_version));
335336
to_backup->parent_backup = INVALID_BACKUP_ID;
@@ -421,7 +422,12 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
421422

422423
/*
423424
* Merging finished, now we can safely update ID of the destination backup.
425+
* TODO: for this critical section we must save incremental backup start_tome
426+
* to FULL backup meta, so even if crash happens after incremental backup removal
427+
* but before full backup obtaining new start_time we could safely continue
428+
* this failed backup.
424429
*/
430+
to_backup->status = BACKUP_STATUS_OK;
425431
to_backup->start_time = from_backup->start_time;
426432
write_backup(to_backup);
427433

0 commit comments

Comments
 (0)