Christopher B. Browne's Home Page
cbbrowne@acm.org

8.65. failednode2(integer, integer, integer, bigint, bigint)

Function Properties

PLPGSQLbigint
FUNCTION failedNode2 (failed_node, backup_node, set_id, ev_seqno, ev_seqfake) On the node that has the highest sequence number of the failed node, fake the FAILOVER_SET event.
    declare
    	p_failed_node		alias for $1;
    	p_backup_node		alias for $2;
    	p_set_id			alias for $3;
    	p_ev_seqno			alias for $4;
    	p_ev_seqfake		alias for $5;
    	v_row				record;
    begin
    	-- ----
    	-- Grab the central configuration lock
    	-- ----
    	lock table sl_config_lock;
    
    	select * into v_row
    			from sl_event
    			where ev_origin = p_failed_node
    			and ev_seqno = p_ev_seqno;
    	if not found then
    		raise exception 'Slony-I: event %,% not found',
    				p_failed_node, p_ev_seqno;
    	end if;
    
    	insert into sl_event
    			(ev_origin, ev_seqno, ev_timestamp,
    			ev_snapshot, 
    			ev_type, ev_data1, ev_data2, ev_data3)
    			values 
    			(p_failed_node, p_ev_seqfake, CURRENT_TIMESTAMP,
    			v_row.ev_snapshot, 
    			'FAILOVER_SET', p_failed_node::text, p_backup_node::text,
    			p_set_id::text);
    	insert into sl_confirm
    			(con_origin, con_received, con_seqno, con_timestamp)
    			values
    			(p_failed_node, getLocalNodeId('_schemadoc'),
    			p_ev_seqfake, CURRENT_TIMESTAMP);
    	notify "_schemadoc_Restart";
    
    	perform failoverSet_int(p_failed_node,
    			p_backup_node, p_set_id, p_ev_seqfake);
    
    	return p_ev_seqfake;
    end;

Google
Contact me at cbbrowne@acm.org