CVS User Account cvsuser
Tue Mar 28 10:59:51 PST 2006
Log Message:
-----------
Bug #1538 - cluster with only 1 node sees sl_log_1, sl_event, et al
perpetually grow; the cleanup thread never clears any data out.

This patch adds a test to the cleanupevent() stored function which
checks to see if there's just one node, and purges all but the last
event if that is so.

Modified Files:
--------------
    slony1-engine/src/backend:
        slony1_funcs.sql (r1.81 -> r1.82)

-------------- next part --------------
Index: slony1_funcs.sql
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.81
retrieving revision 1.82
diff -Lsrc/backend/slony1_funcs.sql -Lsrc/backend/slony1_funcs.sql -u -w -r1.81 -r1.82
--- src/backend/slony1_funcs.sql
+++ src/backend/slony1_funcs.sql
@@ -4513,6 +4513,26 @@
 	end loop;
 
 	-- ----
+	-- If cluster has only one node, then remove all events up to
+	-- the last SYNC - Bug #1538
+        -- http://gborg.postgresql.org/project/slony1/bugs/bugupdate.php?1538
+	-- ----
+
+	select * into v_min_row from @NAMESPACE at .sl_node where
+			no_id <> @NAMESPACE at .getLocalNodeId(''_ at CLUSTERNAME@'') limit 1;
+	if not found then
+		select ev_origin, ev_seqno into v_min_row from @NAMESPACE at .sl_event
+		where ev_origin = @NAMESPACE at .getLocalNodeId(''_ at CLUSTERNAME@'')
+		order by ev_origin desc, ev_seqno desc limit 1;
+		raise notice ''Single node - deleting events < %'', v_min_row.ev_seqno;
+			delete from @NAMESPACE at .sl_event
+			where
+				ev_origin = v_min_row.ev_origin and
+				ev_seqno < v_min_row.ev_seqno;
+
+        end if;
+
+	-- ----
 	-- Also remove stale entries from the nodelock table.
 	-- ----
 	perform @NAMESPACE at .cleanupNodelock();



More information about the Slony1-commit mailing list