CVS User Account cvsuser
Fri Dec 1 14:29:49 PST 2006
Log Message:
-----------
Per Niels Breet...  Need to close file descriptors as part of
slon_worker_terminate() so that we don't chew up file descriptors if
a node's 'master DB' (e.g. - the DB it is managing) is down.

Also put in a 10s pause if attempts to connect to that database fail.
That way, the slon doesn't sit there racing to attempt opening
connections continually if there is some problem with connectivity,
perhaps worsening things, and generating dozens of log entries per
second.

Modified Files:
--------------
    slony1-engine/src/slon:
        slon.c (r1.68 -> r1.69)

-------------- next part --------------
Index: slon.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/slon.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -Lsrc/slon/slon.c -Lsrc/slon/slon.c -u -w -r1.68 -r1.69
--- src/slon/slon.c
+++ src/slon/slon.c
@@ -392,15 +392,17 @@
 	startup_conn = PQconnectdb(rtcfg_conninfo);
 	if (startup_conn == NULL)
 	{
-		slon_log(SLON_FATAL, "main: PQconnectdb() failed\n");
+		slon_log(SLON_FATAL, "main: PQconnectdb() failed - sleep 10s\n");
+		sleep (10);
 		slon_retry();
 		exit(-1);
 	}
 	if (PQstatus(startup_conn) != CONNECTION_OK)
 	{
-		slon_log(SLON_FATAL, "main: Cannot connect to local database - %s\n",
+		slon_log(SLON_FATAL, "main: Cannot connect to local database - %s - sleep 10s\n",
 				 PQerrorMessage(startup_conn));
 		PQfinish(startup_conn);
+		sleep(10);
 		slon_retry();
 		exit(-1);
 	}
@@ -411,7 +413,8 @@
 	rtcfg_nodeid = db_getLocalNodeId(startup_conn);
 	if (rtcfg_nodeid < 0)
 	{
-		slon_log(SLON_FATAL, "main: Node is not initialized properly\n");
+		slon_log(SLON_FATAL, "main: Node is not initialized properly - sleep 10s\n");
+		sleep(10);
 		slon_retry();
 		exit(-1);
 	}
@@ -469,8 +472,9 @@
 				 "set transaction isolation level serializable;");
 	if (PQresultStatus(res) != PGRES_COMMAND_OK)
 	{
-		slon_log(SLON_FATAL, "Cannot start transaction - %s\n",
+		slon_log(SLON_FATAL, "Cannot start transaction - %s - sleep 10s\n",
 				 PQresultErrorMessage(res));
+		sleep (10);
 		PQclear(res);
 		slon_retry();
 	}
@@ -951,7 +955,8 @@
 		kill(slon_worker_pid, SIGKILL);
 		slon_exit(-1);
 	}
-
+        close(sched_wakeuppipe[0]);
+	close(sched_wakeuppipe[1]);
 	alarm(20);
 }
 #endif



More information about the Slony1-commit mailing list