Jan Wieck wieck at lists.slony.info
Wed May 28 12:46:48 PDT 2008
Update of /home/cvsd/slony1/slony1-engine/src/slon
In directory main.slony.info:/tmp/cvs-serv23689/slon

Modified Files:
	dbutils.c remote_worker.c 
Log Message:
Fixed problem where ACCEPT_SET would wait for the corresponding
MOVE_SET or FAILOVER_SET to arrive while holding an exclusive lock
on sl_config_lock, preventing the other remote worker to process
that event.

Jan


Index: remote_worker.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slon/remote_worker.c,v
retrieving revision 1.170
retrieving revision 1.171
diff -C2 -d -r1.170 -r1.171
*** remote_worker.c	28 May 2008 19:09:37 -0000	1.170
--- remote_worker.c	28 May 2008 19:46:46 -0000	1.171
***************
*** 286,290 ****
  	SlonDString query1;
  	SlonDString query2;
! 	SlonDString lsquery;
  	SlonWorkMsg *msg;
  	SlonWorkMsg_event *event;
--- 286,290 ----
  	SlonDString query1;
  	SlonDString query2;
! 	SlonDString query3;
  	SlonWorkMsg *msg;
  	SlonWorkMsg_event *event;
***************
*** 294,297 ****
--- 294,298 ----
  	bool		event_ok;
  	bool		need_reloadListen = false;
+ 	char		conn_symname[32];
  
  	slon_log(SLON_INFO,
***************
*** 305,309 ****
  	if (wd == 0)
  	{
! 		slon_log(SLON_ERROR, "remoteWorkerThread_%d: could not malloc() space for WorkerGroupData\n");
  		slon_retry();
  	}
--- 306,311 ----
  	if (wd == 0)
  	{
! 		slon_log(SLON_ERROR, "remoteWorkerThread_%d: could not malloc() space for WorkerGroupData\n",
! 				node->no_id);
  		slon_retry();
  	}
***************
*** 329,338 ****
  	dstring_init(&query1);
  	dstring_init(&query2);
! 	dstring_init(&lsquery);
  
  	/*
  	 * Connect to the local database
  	 */
! 	if ((local_conn = slon_connectdb(rtcfg_conninfo, "remote_worker")) == NULL)
  		slon_retry();
  	local_dbconn = local_conn->dbconn;
--- 331,341 ----
  	dstring_init(&query1);
  	dstring_init(&query2);
! 	dstring_init(&query3);
  
  	/*
  	 * Connect to the local database
  	 */
! 	sprintf(conn_symname, "remoteWorkerThread_%d", node->no_id);
! 	if ((local_conn = slon_connectdb(rtcfg_conninfo, conn_symname)) == NULL)
  		slon_retry();
  	local_dbconn = local_conn->dbconn;
***************
*** 1009,1016 ****
  					while (PQntuples(res) == 0)
  					{
  						slon_log(SLON_DEBUG1, "ACCEPT_SET - MOVE_SET or FAILOVER_SET not received yet - sleep\n");
  						if (sched_msleep(node, 10000) != SCHED_STATUS_OK)
  							slon_retry();
! 						PQclear(res);
  						res = PQexec(local_dbconn, dstring_data(&query2));
  					}
--- 1012,1039 ----
  					while (PQntuples(res) == 0)
  					{
+ 						PQclear(res);
+ 
  						slon_log(SLON_DEBUG1, "ACCEPT_SET - MOVE_SET or FAILOVER_SET not received yet - sleep\n");
+ 
+ 						/* Rollback the transaction for now */
+ 						(void) slon_mkquery(&query3, "rollback transaction");
+ 						if (query_execute(node, local_dbconn, &query3) < 0)
+ 							slon_retry();
+ 
+ 						/* Sleep */
  						if (sched_msleep(node, 10000) != SCHED_STATUS_OK)
  							slon_retry();
! 
! 						/* Start the transaction again */
! 						(void) slon_mkquery(&query3,
! 							"begin transaction; "
! 							"set transaction isolation level serializable; ");
! 						slon_appendquery(&query1,
! 							 "lock table %s.sl_config_lock; ",
! 							 rtcfg_namespace);
! 						if (query_execute(node, local_dbconn, &query3) < 0)
! 							slon_retry();
! 
! 						/* See if we have the missing event now */
  						res = PQexec(local_dbconn, dstring_data(&query2));
  					}

Index: dbutils.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slon/dbutils.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** dbutils.c	23 Apr 2008 20:35:43 -0000	1.29
--- dbutils.c	28 May 2008 19:46:46 -0000	1.30
***************
*** 147,150 ****
--- 147,168 ----
  		PQclear(res);
  	}
+ 
+ 	if (slon_log_level >= SLON_DEBUG1)
+ 	{
+ 		slon_mkquery(&query, "select pg_backend_pid()");
+ 		res = PQexec(dbconn, dstring_data(&query));
+ 		if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
+ 		{
+ 			slon_log(SLON_ERROR, "%s: Unable to get backend pid - %s\n",
+ 				symname, PQresultErrorMessage(res));
+ 		}
+ 		else
+ 		{
+ 			slon_log(SLON_DEBUG1, "%s \"%s\": backend pid = %s\n",
+ 				symname, conninfo, PQgetvalue(res, 0, 0));
+ 		}
+ 		PQclear(res);
+ 	}
+ 
  	dstring_free(&query);
  	return conn;



More information about the Slony1-commit mailing list