summaryrefslogtreecommitdiff
path: root/src/bin/pg_ctl/pg_ctl.c
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2008-04-23 13:44:59 +0000
committerMagnus Hagander <magnus@hagander.net>2008-04-23 13:44:59 +0000
commitc979a1fefafcc83553bf218c7f2270cad77ea31d (patch)
tree7bbf70239a28d7bd5bf239fd93ebc1f37a85c39e /src/bin/pg_ctl/pg_ctl.c
parentcf23b75b4dce75151df7164ed72263e66b758ae9 (diff)
Prevent shutdown in normal mode if online backup is running, and
have pg_ctl warn about this. Cancel running online backups (by renaming the backup_label file, thus rendering the backup useless) when shutting down in fast mode. Laurenz Albe
Diffstat (limited to 'src/bin/pg_ctl/pg_ctl.c')
-rw-r--r--src/bin/pg_ctl/pg_ctl.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 89fc34d6860..55319c6262b 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-2008, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.96 2008/02/29 23:31:20 adunstan Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.97 2008/04/23 13:44:59 mha Exp $
*
*-------------------------------------------------------------------------
*/
@@ -144,6 +144,7 @@ static char def_postopts_file[MAXPGPATH];
static char postopts_file[MAXPGPATH];
static char pid_file[MAXPGPATH];
static char conf_file[MAXPGPATH];
+static char backup_file[MAXPGPATH];
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
static void unlimit_core_size(void);
@@ -731,6 +732,7 @@ do_stop(void)
{
int cnt;
pgpid_t pid;
+ struct stat statbuf;
pid = get_pgpid();
@@ -763,6 +765,12 @@ do_stop(void)
}
else
{
+ if ((shutdown_mode == SMART_MODE) && (stat(backup_file, &statbuf) == 0))
+ {
+ print_msg(_("WARNING: online backup mode is active; must be ended\n"
+ " with pg_stop_backup() for shutdown to complete\n\n"));
+ }
+
print_msg(_("waiting for server to shut down..."));
for (cnt = 0; cnt < wait_seconds; cnt++)
@@ -799,6 +807,7 @@ do_restart(void)
{
int cnt;
pgpid_t pid;
+ struct stat statbuf;
pid = get_pgpid();
@@ -833,6 +842,12 @@ do_restart(void)
exit(1);
}
+ if ((shutdown_mode == SMART_MODE) && (stat(backup_file, &statbuf) == 0))
+ {
+ print_msg(_("WARNING: online backup mode is active; must be ended\n"
+ " with pg_stop_backup() for shutdown to complete\n\n"));
+ }
+
print_msg(_("waiting for server to shut down..."));
/* always wait for restart */
@@ -1883,6 +1898,7 @@ main(int argc, char **argv)
snprintf(postopts_file, MAXPGPATH, "%s/postmaster.opts", pg_data);
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);
}
switch (ctl_command)