Jan Wieck wieck at lists.slony.info
Fri Aug 10 11:32:23 PDT 2007
Update of /home/cvsd/slony1/slony1-engine/src/slon
In directory main.slony.info:/tmp/cvs-serv23862/src/slon

Modified Files:
      Tag: REL_1_2_STABLE
	remote_worker.c 
Log Message:
Fix archive logging for replicated sequences.

Jan


Index: remote_worker.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slon/remote_worker.c,v
retrieving revision 1.124.2.18
retrieving revision 1.124.2.19
diff -C2 -d -r1.124.2.18 -r1.124.2.19
*** remote_worker.c	29 Jul 2007 17:29:18 -0000	1.124.2.18
--- remote_worker.c	10 Aug 2007 18:32:21 -0000	1.124.2.19
***************
*** 3741,3744 ****
--- 3741,3745 ----
  		return -1;
  	}
+ 	PQclear(res1);
  	if (archive_dir)
  	{
***************
*** 3751,3755 ****
  		{
  			slon_log(SLON_ERROR, "remoteWorkerThread_%d: "
! 					 " could not insert to sl_setsync_offline",
  					 node->no_id);
  			PQclear(res1);
--- 3752,3798 ----
  		{
  			slon_log(SLON_ERROR, "remoteWorkerThread_%d: "
! 					 " could not add data to archive",
! 					 node->no_id);
! 			slon_disconnectdb(pro_conn);
! 			dstring_free(&query1);
! 			dstring_free(&query2);
! 			dstring_free(&query3);
! 			dstring_free(&lsquery);
! 			dstring_free(&indexregenquery);
! 			archive_terminate(node);
! 			return -1;
! 		}
! 
! 		/*
! 		 * Refresh the sl_sequence_offline table
! 		 */
! 		slon_mkquery(&lsquery,
! 				"delete from %s.sl_sequence_offline;\n",
! 				rtcfg_namespace);
! 		rc = archive_append_ds(node, &lsquery);
! 		if (rc < 0)
! 		{
! 			slon_log(SLON_ERROR, "remoteWorkerThread_%d: "
! 					 " could not add data to archive",
! 					 node->no_id);
! 			slon_disconnectdb(pro_conn);
! 			dstring_free(&query1);
! 			dstring_free(&query2);
! 			dstring_free(&query3);
! 			dstring_free(&lsquery);
! 			dstring_free(&indexregenquery);
! 			archive_terminate(node);
! 			return -1;
! 		}
! 
! 		slon_mkquery(&query1,
! 				"select seq_id, seq_relname, seq_nspname "
! 				"from %s.sl_sequence; ",
! 				rtcfg_namespace);
! 		res1 = PQexec(pro_dbconn, dstring_data(&query1));
! 		if (PQresultStatus(res1) != PGRES_TUPLES_OK)
! 		{
! 			slon_log(SLON_ERROR, "remoteWorkerThread_%d: "
! 					 " could not select from sl_sequence",
  					 node->no_id);
  			PQclear(res1);
***************
*** 3763,3768 ****
  			return -1;
  		}
  	}
- 	PQclear(res1);
  	gettimeofday(&tv_now, NULL);
  	slon_log(SLON_DEBUG2, "remoteWorkerThread_%d: "
--- 3806,3841 ----
  			return -1;
  		}
+ 
+ 		ntuples1 = PQntuples(res1);
+ 		for (tupno1 = 0; tupno1 < ntuples1; tupno1++)
+ 		{
+ 			slon_mkquery(&lsquery,
+ 					"insert into %s.sl_sequence_offline "
+ 					"(seq_id, seq_relname, seq_nspname) "
+ 					"values ('%q', '%q', '%q'); ",
+ 					rtcfg_namespace,
+ 					PQgetvalue(res1, tupno1, 0),
+ 					PQgetvalue(res1, tupno1, 1),
+ 					PQgetvalue(res1, tupno1, 2));
+ 			
+ 			rc = archive_append_ds(node, &lsquery);
+ 			if (rc < 0)
+ 			{
+ 				slon_log(SLON_ERROR, "remoteWorkerThread_%d: "
+ 						 " could not add data to archive",
+ 						 node->no_id);
+ 				PQclear(res1);
+ 				slon_disconnectdb(pro_conn);
+ 				dstring_free(&query1);
+ 				dstring_free(&query2);
+ 				dstring_free(&query3);
+ 				dstring_free(&lsquery);
+ 				dstring_free(&indexregenquery);
+ 				archive_terminate(node);
+ 				return -1;
+ 			}
+ 		}
+ 		PQclear(res1);
  	}
  	gettimeofday(&tv_now, NULL);
  	slon_log(SLON_DEBUG2, "remoteWorkerThread_%d: "



More information about the Slony1-commit mailing list