Re: [PATCHES] [pgsql-hackers-win32] Service startup delay
Patch applied. Thanks. --- Dave Page wrote: -Original Message- From: Bruce Momjian [mailto:[EMAIL PROTECTED] Sent: 26 August 2004 02:44 To: Max Dunn Cc: Dave Page; 'Barry Lind'; [EMAIL PROTECTED] Subject: Re: [pgsql-hackers-win32] Service startup delay Another issue is that when installing the Postgres service with pg_ctl register -w the -w parameter was not put in the registry ImagePath value for the Postgres service. (I added it manually to test.) So I suspect that pg_ctl register will need to be enhanced to add the -w parameter to the registry settings. Would a Win32 guy look at this? No problem. Regards, Dave. === RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_ctl/pg_ctl.c,v retrieving revision 1.25 diff -u -r1.25 pg_ctl.c --- pg_ctl.c 21 Aug 2004 03:12:55 - 1.25 +++ pg_ctl.c 26 Aug 2004 14:37:13 - @@ -832,6 +832,9 @@ strcat(cmdLine,\); } + if (do_wait) + strcat(cmdLine, -w); + if (post_opts) { strcat(cmdLine, ); @@ -1038,7 +1041,7 @@ printf(_( %s status [-D DATADIR]\n), progname); printf(_( %s killSIGNALNAME PROCESSID\n), progname); #ifdef WIN32 - printf(_( %s register [-N servicename] [-U username] [-P password] [-D DATADIR] [-o \OPTIONS\]\n), progname); + printf(_( %s register [-N servicename] [-U username] [-P password] [-D DATADIR] [-w] [-o \OPTIONS\]\n), progname); printf(_( %s unregister [-N servicename]\n), progname); #endif printf(_(Common options:\n)); -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 8: explain analyze is your friend
Re: [PATCHES] [pgsql-hackers-win32] Service startup delay
-Original Message- From: Bruce Momjian [mailto:[EMAIL PROTECTED] Sent: 26 August 2004 02:44 To: Max Dunn Cc: Dave Page; 'Barry Lind'; [EMAIL PROTECTED] Subject: Re: [pgsql-hackers-win32] Service startup delay Another issue is that when installing the Postgres service with pg_ctl register -w the -w parameter was not put in the registry ImagePath value for the Postgres service. (I added it manually to test.) So I suspect that pg_ctl register will need to be enhanced to add the -w parameter to the registry settings. Would a Win32 guy look at this? No problem. Regards, Dave. === RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_ctl/pg_ctl.c,v retrieving revision 1.25 diff -u -r1.25 pg_ctl.c --- pg_ctl.c21 Aug 2004 03:12:55 - 1.25 +++ pg_ctl.c26 Aug 2004 14:37:13 - @@ -832,6 +832,9 @@ strcat(cmdLine,\); } + if (do_wait) + strcat(cmdLine, -w); + if (post_opts) { strcat(cmdLine, ); @@ -1038,7 +1041,7 @@ printf(_( %s status [-D DATADIR]\n), progname); printf(_( %s killSIGNALNAME PROCESSID\n), progname); #ifdef WIN32 - printf(_( %s register [-N servicename] [-U username] [-P password] [-D DATADIR] [-o \OPTIONS\]\n), progname); + printf(_( %s register [-N servicename] [-U username] [-P password] [-D DATADIR] [-w] [-o \OPTIONS\]\n), progname); printf(_( %s unregister [-N servicename]\n), progname); #endif printf(_(Common options:\n)); ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [PATCHES] [pgsql-hackers-win32] Service startup delay
OK, I started running tests with pg_ctl -w and found it did not work even on Unix. I found that the code was not checking the return value of PQsetdbLogin(), and wasn't looping properly using a sleep. The attached applied patch should fix should fix your reported problem. --- Max Dunn wrote: I tried adding the -w option to the registry entry for starting the Postgres service(see below) but it didn't help; Tomcat still started before Postgres was ready: c:\Program Files\Xythos\WebFile Server Evaluation\pgsql\binsc qc postgresql [SC] GetServiceConfig SUCCESS SERVICE_NAME: postgresql TYPE : 10 WIN32_OWN_PROCESS START_TYPE : 2 AUTO_START ERROR_CONTROL : 1 NORMAL BINARY_PATH_NAME : C:/Program Files/Xythos/WebFile Server Evaluation/p gsql/bin/pg_ctl.exe runservice -w -N PostgreSQL -D C:/Program Files/Xythos/We bFile Server Evaluation/pgsql/data -o -i LOAD_ORDER_GROUP : TAG: 0 DISPLAY_NAME : PostgreSQL DEPENDENCIES : RPCSS SERVICE_START_NAME : .\postgres --Max -Original Message- From: Dave Page [mailto:[EMAIL PROTECTED] Sent: Friday, August 20, 2004 4:09 PM To: Bruce Momjian; Barry Lind Cc: [EMAIL PROTECTED]; Max Dunn Subject: RE: [pgsql-hackers-win32] Service startup delay -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bruce Momjian Sent: 20 August 2004 19:00 To: Barry Lind Cc: [EMAIL PROTECTED]; Max Dunn Subject: Re: [pgsql-hackers-win32] Service startup delay I think you need to use 'pg_ctl -w' to wait for it to start. Does -w work when starting in service mode? Aside from that, one possible problem with this is what happens if the database goes into recovery mode at startup. Whilst waiting for that to run, I would think it's possible that the service control manager would timeout waiting for the service to complete startup. Regards, Dave. ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 Index: src/bin/pg_ctl/pg_ctl.c === RCS file: /cvsroot/pgsql-server/src/bin/pg_ctl/pg_ctl.c,v retrieving revision 1.24 diff -c -c -r1.24 pg_ctl.c *** src/bin/pg_ctl/pg_ctl.c 29 Jul 2004 16:11:11 - 1.24 --- src/bin/pg_ctl/pg_ctl.c 21 Aug 2004 03:07:25 - *** *** 404,415 for (i = 0; i wait_seconds; i++) { ! if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL, template1, NULL, NULL)) != NULL) { PQfinish(conn); success = true; break; } } return success; --- 404,426 for (i = 0; i wait_seconds; i++) { ! if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL, ! template1, NULL, NULL)) != NULL ! PQstatus(conn) == CONNECTION_OK) { PQfinish(conn); success = true; break; } + else + { + if (!silence_echo) + { + printf(.); + fflush(stdout); + } + pg_usleep(100); /* 1 sec */ + } } return success; ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster