You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-05 00:28:52 +02:00
Prevent invalid recovery when backup_label removed.
If backup_label is removed from a restored backup then PostgreSQL will instead use checkpoint information from pg_control to attempt (what is thinks is) crash recovery. This will nearly always result in a corrupt cluster because the checkpoint will not be from the beginning of the backup, and even if it is, the end point will not be specified, which could lead to recovery stopping too early. To prevent this, invalidate the checkpoint LSN in pg_control on restore. If backup_label is removed then recovery will still fail because PostgreSQL will not be able to find the invalid checkpoint. The LSN of the checkpoint is not logged but it will be visible in pg_controldata output as 0/DEAD. This value is invalid because PostgreSQL always skips the first WAL segment when initializing a cluster.
This commit is contained in:
@ -92,6 +92,22 @@ Get control crc offset
|
||||
|
||||
#endif
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Invalidate control checkpoint. PostgreSQL skips the first segment so any LSN in that segment is invalid.
|
||||
***********************************************************************************************************************************/
|
||||
#if PG_VERSION > PG_VERSION_MAX
|
||||
|
||||
#elif PG_VERSION >= PG_VERSION_93
|
||||
|
||||
#define PG_INTERFACE_CONTROL_CHECKPOINT_INVALIDATE(version) \
|
||||
static void \
|
||||
pgInterfaceControlCheckpointInvalidate##version(unsigned char *const controlFile) \
|
||||
{ \
|
||||
((ControlFileData *)controlFile)->checkPoint = PG_CONTROL_CHECKPOINT_INVALID; \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get the control version
|
||||
***********************************************************************************************************************************/
|
||||
|
Reference in New Issue
Block a user