Apologies in advance as my original attempt to send this message may well get
through in a day or so now that Bob the Builder has finished digging up my
fibre and copper and the telco has set about joining them all back together and
burying them again.

Anyway... the attached patch to pg_autovacuum follows Tom's earlier suggestion
that it re-try the inital database connection every 30 seconds for 5 minutes
before aborting when starting as a Windows Service.

Any chance of getting this in before 8.0.1?

Cheers, Dave.
Index: pg_autovacuum.c
===================================================================
RCS file: /projects/cvsroot/pgsql/contrib/pg_autovacuum/pg_autovacuum.c,v
retrieving revision 1.28
diff -u -r1.28 pg_autovacuum.c
--- pg_autovacuum.c	24 Jan 2005 00:13:38 -0000	1.28
+++ pg_autovacuum.c	25 Jan 2005 11:46:44 -0000
@@ -556,6 +556,7 @@
 	Dllist	   *db_list = DLNewList();
 	db_info    *dbs = NULL;
 	PGresult   *res = NULL;
+    int        j = 0, k = 0;
 
 	DLAddHead(db_list, DLNewElem(init_dbinfo((char *) "template1", 0, 0)));
 	if (DLGetHead(db_list) == NULL)
@@ -571,6 +572,28 @@
 	 */
 	dbs = ((db_info *) DLE_VAL(DLGetHead(db_list)));
 	dbs->conn = db_connect(dbs);
+    
+#ifdef WIN32
+    while (dbs->conn == NULL && !appMode && k < 10)
+    {
+        /* 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)
 	{
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to