Adjust Windows autovacuum service to retry for up to 5 minutes waiting

for the postmaster to start.  Dave Page
This commit is contained in:
Tom Lane 2005-01-26 22:25:13 +00:00
parent bf7737a938
commit b0e3dd7e61

View File

@ -4,7 +4,7 @@
* Revisions by Christopher B. Browne, Liberty RMS
* Win32 Service code added by Dave Page
*
* $PostgreSQL: pgsql/contrib/pg_autovacuum/pg_autovacuum.c,v 1.28 2005/01/24 00:13:38 neilc Exp $
* $PostgreSQL: pgsql/contrib/pg_autovacuum/pg_autovacuum.c,v 1.29 2005/01/26 22:25:13 tgl Exp $
*/
#include "postgres_fe.h"
@ -556,6 +556,9 @@ init_db_list(void)
Dllist *db_list = DLNewList();
db_info *dbs = NULL;
PGresult *res = NULL;
#ifdef WIN32
int k = 0;
#endif
DLAddHead(db_list, DLNewElem(init_dbinfo((char *) "template1", 0, 0)));
if (DLGetHead(db_list) == NULL)
@ -572,6 +575,30 @@ init_db_list(void)
dbs = ((db_info *) DLE_VAL(DLGetHead(db_list)));
dbs->conn = db_connect(dbs);
#ifdef WIN32
while (dbs->conn == NULL && !appMode && k < 10)
{
int j;
/* Pause for 30 seconds to allow the database to start up */
log_entry("Pausing 30 seconds to allow the database to startup completely", LVL_INFO);
fflush(LOGOUTPUT);
ServiceStatus.dwWaitHint = 10;
for (j=0; j<6; j++)
{
pg_usleep(5000000);
ServiceStatus.dwCheckPoint++;
SetServiceStatus(hStatus, &ServiceStatus);
fflush(LOGOUTPUT);
}
/* now try again */
log_entry("Attempting to connect again.", LVL_INFO);
dbs->conn = db_connect(dbs);
k++;
}
#endif
if (dbs->conn != NULL)
{
res = send_query(FROZENOID_QUERY, dbs);