CVS User Account cvsuser
Mon Jan 30 11:23:13 PST 2006
Log Message:
-----------
slon SUBSCRIBE_SET event now requests an exclusive lock on each table
being subscribed to at the start of the event. If that fails, it won't
waste any time copying data.

This guarantees that the SUBSCRIBE_SET event will have full control
over those tables from the very beginning.

[Note:  Unit tested via running 'test1' from test bed...]

Modified Files:
--------------
    slony1-engine/src/slon:
        remote_worker.c (r1.103 -> r1.104)

-------------- next part --------------
Index: remote_worker.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/remote_worker.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -Lsrc/slon/remote_worker.c -Lsrc/slon/remote_worker.c -u -w -r1.103 -r1.104
--- src/slon/remote_worker.c
+++ src/slon/remote_worker.c
@@ -2822,6 +2822,26 @@
 				return -1;
 			}
 		}
+		/* Request an exclusive lock on each table
+
+		   We do this immediately so that we don't get stuck
+		   later if something else had been holding onto one
+		   or another table.
+		 */
+		
+		slon_mkquery(&query3, "lock table %s;\n", tab_fqname);
+		res2 = PQexec(loc_dbconn, dstring_data(&query3));
+		if (PQresultStatus(res2) != PGRES_COMMAND_OK)
+		{
+			slon_log(SLON_ERROR, "remoteWorkerThread_%d: Could not lock table %s "
+				 "on subscriber\n", node->no_id, tab_fqname);
+			PQclear(res2);
+			slon_disconnectdb(pro_conn);
+			dstring_free(&query1);
+			dstring_free(&query3);
+			terminate_log_archive();
+			return -1;
+		}
 	}
 	PQclear(res1);
 



More information about the Slony1-commit mailing list