aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_ctl/pg_ctl.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 98bbaefd8c8..7af3b913ffc 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -411,10 +411,14 @@ start_postmaster(void)
static PGPing
test_postmaster_connection(bool do_checkpoint)
{
- PGPing ret = PQPING_OK; /* assume success for wait == zero */
+ PGPing ret = PQPING_NO_RESPONSE;
char connstr[MAXPGPATH * 2 + 256];
int i;
+ /* if requested wait time is zero, return "still starting up" code */
+ if (wait_seconds <= 0)
+ return PQPING_REJECT;
+
connstr[0] = '\0';
for (i = 0; i < wait_seconds; i++)
@@ -538,6 +542,19 @@ test_postmaster_connection(bool do_checkpoint)
break;
}
+ /*
+ * The postmaster should create postmaster.pid very soon after being
+ * started. If it's not there after we've waited 5 or more seconds,
+ * assume startup failed and give up waiting.
+ */
+ if (i >= 5)
+ {
+ struct stat statbuf;
+
+ if (stat(pid_file, &statbuf) != 0)
+ return PQPING_NO_RESPONSE;
+ }
+
/* No response, or startup still in process; wait */
#if defined(WIN32)
if (do_checkpoint)