Christopher Browne cbbrowne
Fri Nov 12 18:16:41 PST 2004
One of the things that proves "unfortunate" is if a slon falls over on
the origin node.  This has the result that SYNC events are not being
run (in sync_thread.c), and hence that transactions build up into One
Grand Big Sync.

This function should be the thing that gets executed...

The thing I'm _not_ sure of is where it would get linked in.  I expect
it should get executed somehow by _Slony_I_logTrigger(), but
presumably not directly so, because:

  a) This shouldn't happen in EVERY update, because the burden of
     running the query on sl_event would get pretty high, and

  b) It probably shouldn't happen more than once per XID...

In view of the fact that this function isn't referenced by anything
yet, it's pretty safe to have it in CVS :-).  (I ran through some of
the duct tape tests, so it hasn't busted anything...)  

Making it useful: next step...

-- ----------------------------------------------------------------------
-- 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.';
-- 
"cbbrowne","@","ca.afilias.info"
<http://dev6.int.libertyrms.com/>
Christopher Browne
(416) 673-4124 (land)


More information about the Slony1-general mailing list