summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-09-14 08:05:54 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-09-14 08:05:54 +0000
commit105faeb3569b83a2bb2a6b6e367b77d1c51c1789 (patch)
treed31dd24fa9fd0c1182a2a15f55f942c87d9d451d /src
parent3b08e09fe7bc2640930aaa9e6d284700f4920f5f (diff)
Don't warn about an in-progress online backup, when we're recovering from
an online backup instead of performing one. pg_ctl can detect that by checking if recovery.conf exists. Backup label file is renamed away early in recovery, so the window where backup label exists during recovery is normally very small, but you can run into it e.g if restore_command is set incorrectly and the startup process never finds even the first WAL segment containing the checkpoint record to start recovery from. Fujii Masao with comments by me.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_ctl/pg_ctl.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 810f6fef6e3..dad7e8b79df 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -4,7 +4,7 @@
*
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.122 2010/04/07 03:48:51 itagaki Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.122.2.1 2010/09/14 08:05:54 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -142,6 +142,7 @@ static char postopts_file[MAXPGPATH];
static char pid_file[MAXPGPATH];
static char conf_file[MAXPGPATH];
static char backup_file[MAXPGPATH];
+static char recovery_file[MAXPGPATH];
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
static void unlimit_core_size(void);
@@ -802,7 +803,15 @@ do_stop(void)
}
else
{
- if ((shutdown_mode == SMART_MODE) && (stat(backup_file, &statbuf) == 0))
+ /*
+ * If backup_label exists, an online backup is running. Warn the
+ * user that smart shutdown will wait for it to finish. However, if
+ * recovery.conf is also present, we're recovering from an online
+ * backup instead of performing one.
+ */
+ if (shutdown_mode == SMART_MODE &&
+ stat(backup_file, &statbuf) == 0 &&
+ stat(recovery_file, &statbuf) != 0)
{
print_msg(_("WARNING: online backup mode is active\n"
"Shutdown will not complete until pg_stop_backup() is called.\n\n"));
@@ -879,7 +888,15 @@ do_restart(void)
exit(1);
}
- if ((shutdown_mode == SMART_MODE) && (stat(backup_file, &statbuf) == 0))
+ /*
+ * If backup_label exists, an online backup is running. Warn the
+ * user that smart shutdown will wait for it to finish. However, if
+ * recovery.conf is also present, we're recovering from an online
+ * backup instead of performing one.
+ */
+ if (shutdown_mode == SMART_MODE &&
+ stat(backup_file, &statbuf) == 0 &&
+ stat(recovery_file, &statbuf) != 0)
{
print_msg(_("WARNING: online backup mode is active\n"
"Shutdown will not complete until pg_stop_backup() is called.\n\n"));
@@ -1962,6 +1979,7 @@ main(int argc, char **argv)
snprintf(pid_file, MAXPGPATH, "%s/postmaster.pid", pg_data);
snprintf(conf_file, MAXPGPATH, "%s/postgresql.conf", pg_data);
snprintf(backup_file, MAXPGPATH, "%s/backup_label", pg_data);
+ snprintf(recovery_file, MAXPGPATH, "%s/recovery.conf", pg_data);
}
switch (ctl_command)