aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2008-05-09 14:27:47 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2008-05-09 14:27:47 +0000
commitf0eb3e5e580f0ac95cb451f931dac4352cb9adba (patch)
treec38d1509a79f19e1989cab6aafa6116345c25d30 /contrib
parent706fcbd8208e9e3c0de62ff07f7e8541bbd8ccce (diff)
downloadpostgresql-f0eb3e5e580f0ac95cb451f931dac4352cb9adba.tar.gz
postgresql-f0eb3e5e580f0ac95cb451f931dac4352cb9adba.zip
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.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/pg_standby/pg_standby.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/contrib/pg_standby/pg_standby.c b/contrib/pg_standby/pg_standby.c
index 41b3500dd11..9879348cc1b 100644
--- a/contrib/pg_standby/pg_standby.c
+++ b/contrib/pg_standby/pg_standby.c
@@ -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);
}