Mon Jan 24 18:42:47 PST 2005
- Previous message: [Slony1-commit] By cbbrowne: Apply changes from CVS HEAD admin guide into the stable
- Next message: [Slony1-commit] By cbbrowne: Shell script that uses the new function for generating SYNC
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Log Message: ----------- Added in stored function for generating SYNC events Tags: ---- REL_1_0_STABLE Modified Files: -------------- slony1-engine/src/backend: slony1_funcs.sql (r1.15.2.10 -> r1.15.2.11) -------------- next part -------------- Index: slony1_funcs.sql =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.sql,v retrieving revision 1.15.2.10 retrieving revision 1.15.2.11 diff -Lsrc/backend/slony1_funcs.sql -Lsrc/backend/slony1_funcs.sql -u -w -r1.15.2.10 -r1.15.2.11 --- src/backend/slony1_funcs.sql +++ src/backend/slony1_funcs.sql @@ -3714,7 +3714,10 @@ return p_sub_set; end; ' language plpgsql; - +comment on function @NAMESPACE at .enableSubscription_int (int4, int4, int4) is +'Internal function to handle enabling of a subscription. +The real work is done in slon; this function just needs to update +sl_subscribe to indicate that it occurred.'; -- ---------------------------------------------------------------------- -- FUNCTION forwardConfirm () @@ -3746,7 +3749,8 @@ return v_max_seqno; end; ' language plpgsql; - +comment on function @NAMESPACE at .forwardConfirm(int4, int4, int8, timestamp) is +'Store and forward a confirmation that a SYNC has been received.'; -- ---------------------------------------------------------------------- -- FUNCTION cleanupEvent () @@ -3761,7 +3765,8 @@ v_max_sync int8; begin -- ---- - -- First remove all but the oldest confirm row per origin,receiver pair + -- First remove all sl_confirm entries pointing to origins/receivers + -- that do not exist anymore in sl_node -- ---- delete from @NAMESPACE at .sl_confirm where con_origin not in (select no_id from @NAMESPACE at .sl_node); @@ -3808,7 +3813,14 @@ return 0; end; ' language plpgsql; +comment on function @NAMESPACE at .cleanupEvent() is +'Purges old data, getting rid of: + 1. Obsolete sl_confirm entries that reference nonexistent nodes + 2. All but the oldest confirm row for each (origin,receiver) pair, + ignoring young confirmations + 3. All events that have been confirmed by all nodes in the entire + cluster'; -- ---------------------------------------------------------------------- -- FUNCTION tableAddKey (tab_fqname) @@ -4229,6 +4241,36 @@ ' language plpgsql; +-- ---------------------------------------------------------------------- +-- FUNCTION generate_sync_event (interval) +-- +-- This code can be used to create SYNC events every once in a while +-- even if the 'master' slon daemon is down +-- ---------------------------------------------------------------------- +create or replace function @NAMESPACE at .generate_sync_event(interval) +returns int4 +as ' +declare + p_interval alias for $1; + v_node_row record; + +BEGIN + select 1 into v_node_row from @NAMESPACE at .sl_event + where ev_type = ''SYNC'' and ev_origin = @NAMESPACE at .getLocalNodeId(''@NAMESPACE@'') + and ev_timestamp > now() - p_interval limit 1; + if not found then + -- If there has been no SYNC in the last interval, then push one + perform @NAMESPACE at .createEvent(''@NAMESPACE@'', ''SYNC'', NULL); + return 1; + else + return 0; + end if; +end; +' language plpgsql; + +comment on function @NAMESPACE at .generate_sync_event(interval) is + 'Generate a sync event if there has not been one in 30 seconds.'; + -- ********************************************************************** -- * Views -- **********************************************************************
- Previous message: [Slony1-commit] By cbbrowne: Apply changes from CVS HEAD admin guide into the stable
- Next message: [Slony1-commit] By cbbrowne: Shell script that uses the new function for generating SYNC
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list