Fri Nov 12 18:17:53 PST 2004
- Previous message: [Slony1-commit] By cbbrowne: Add in debugging code, comment out actual execution of
- Next message: [Slony1-commit] By cbbrowne: Add FUNCTION generate_sync_event () - to try to add SYNCs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Log Message:
-----------
Add FUNCTION generate_sync_event () - to try to add SYNCs even if slon isn't running
Modified Files:
--------------
slony1-engine/src/backend:
slony1_funcs.sql (r1.39 -> r1.40)
-------------- next part --------------
Index: slony1_funcs.sql
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.sql,v
retrieving revision 1.39
retrieving revision 1.40
diff -Lsrc/backend/slony1_funcs.sql -Lsrc/backend/slony1_funcs.sql -u -w -r1.39 -r1.40
--- src/backend/slony1_funcs.sql
+++ src/backend/slony1_funcs.sql
@@ -4575,6 +4575,33 @@
allow communications between nodes in the Slony-I cluster.';
-- ----------------------------------------------------------------------
+-- FUNCTION generate_sync_event ()
+--
+-- This code will be run from inside the logtrigger() function,
+-- and will create SYNC events every once in a while...
+-- ----------------------------------------------------------------------
+create or replace function @NAMESPACE at .generate_sync_event()
+returns int4
+as '
+declare
+ v_leventtime timestamptz;
+
+BEGIN
+ -- When was the last SYNC on this node?
+ select ev_timestamp into v_leventtime from @NAMESPACE at .sl_event
+ where ev_type = ''SYNC'' and ev_origin = @NAMESPACE at .getLocalNodeId()
+ order by ev_origin, ev_seqno desc limit 1;
+
+ -- If there has been no SYNC in the last 30 seconds, then push one
+ if ev_timestamp + ''30 s''::interval < now() then
+ select @NAMESPACE at .createEvent(''@NAMESPACE@'', ''SYNC'', NULL);
+ end if;
+END' language plpgsql;
+
+comment on function @NAMESPACE at .generate_sync_event() is
+ 'Generate a sync event if there has not been one in 30 seconds.';
+
+-- ----------------------------------------------------------------------
-- FUNCTION tableHasSerialKey (tab_fqname)
--
-- Checks if a table has our special serial key column that is
- Previous message: [Slony1-commit] By cbbrowne: Add in debugging code, comment out actual execution of
- Next message: [Slony1-commit] By cbbrowne: Add FUNCTION generate_sync_event () - to try to add SYNCs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list