1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Fix incorrect archive truncation point calculation in the %r recovery_command

parameter. This fixes bug 4137 reported by Wojciech Strzalka, where a WAL
file is deleted too early when starting the recovery of a warm standby server.

Also add a sanity check in pg_standby so that it will refuse to delete anything
earlier than the file being restored, and improve the debug message in case
nothing is deleted.

Simon Riggs. Backpatch to 8.3, which is where %r was introduced.
This commit is contained in:
Heikki Linnakangas
2008-05-09 14:28:08 +00:00
parent 65a1e96c1d
commit 48bf6642c3
2 changed files with 44 additions and 7 deletions

View File

@ -297,6 +297,15 @@ SetWALFileNameForCleanup(void)
if (restartWALFileName)
{
/*
* Don't do cleanup if the restartWALFileName provided
* is later than the xlog file requested. This is an error
* and we must not remove these files from archive.
* This shouldn't happen, but better safe than sorry.
*/
if (strcmp(restartWALFileName, nextWALFileName) > 0)
return false;
strcpy(exclusiveCleanupFileName, restartWALFileName);
return true;
}
@ -584,7 +593,11 @@ main(int argc, char **argv)
fprintf(stderr, "\nMax wait interval : %d %s",
maxwaittime, (maxwaittime > 0 ? "seconds" : "forever"));
fprintf(stderr, "\nCommand for restore : %s", restoreCommand);
fprintf(stderr, "\nKeep archive history : %s and later", exclusiveCleanupFileName);
fprintf(stderr, "\nKeep archive history : ");
if (need_cleanup)
fprintf(stderr, "%s and later", exclusiveCleanupFileName);
else
fprintf(stderr, "No cleanup required");
fflush(stderr);
}