Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0bae3bc

Browse files
committed
Improve corner cases in pg_ctl's new wait-for-postmaster-startup code.
With "-w -t 0", we should report "still starting up", not "ok". If wefall out of the loop without ever being able to call PQping (because wewere never able to construct a connection string), report "no response",not "ok". This gets rid of corner cases in which we'd claim the serverhad started even though it had not.Also, if the postmaster.pid file is not there at any point after we'vewaited 5 seconds, assume the postmaster has failed and report that, ratherthan almost-certainly-fruitlessly continuing to wait. The pidfile shouldappear almost instantly even when there is extensive startup work to do,so 5 seconds is already a very conservative figure. This part is per agripe from MauMau --- there might be better ways to do it, but nothingsimple enough to get done for 9.1.
1 parent90857b4 commit0bae3bc

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,14 @@ start_postmaster(void)
411411
staticPGPing
412412
test_postmaster_connection(booldo_checkpoint)
413413
{
414-
PGPingret=PQPING_OK;/* assume success for wait == zero */
414+
PGPingret=PQPING_NO_RESPONSE;
415415
charconnstr[MAXPGPATH*2+256];
416416
inti;
417417

418+
/* if requested wait time is zero, return "still starting up" code */
419+
if (wait_seconds <=0)
420+
returnPQPING_REJECT;
421+
418422
connstr[0]='\0';
419423

420424
for (i=0;i<wait_seconds;i++)
@@ -538,6 +542,19 @@ test_postmaster_connection(bool do_checkpoint)
538542
break;
539543
}
540544

545+
/*
546+
* The postmaster should create postmaster.pid very soon after being
547+
* started. If it's not there after we've waited 5 or more seconds,
548+
* assume startup failed and give up waiting.
549+
*/
550+
if (i >=5)
551+
{
552+
structstatstatbuf;
553+
554+
if (stat(pid_file,&statbuf)!=0)
555+
returnPQPING_NO_RESPONSE;
556+
}
557+
541558
/* No response, or startup still in process; wait */
542559
#if defined(WIN32)
543560
if (do_checkpoint)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp