failednode2(p_failed_nodes integer, p_ev_seqno integer, p_backup_node bigint, p_failed_node integer[])

8.64. failednode2(p_failed_nodes integer, p_ev_seqno integer, p_backup_node bigint, p_failed_node integer[])

Function Properties

Language: PLPGSQL

Return Type: bigint

FUNCTION failedNode2 (failed_node, backup_node, set_id, ev_seqno, ev_seqfake,p_failed_nodes) On the node that has the highest sequence number of the failed node, fake the FAILOVER_SET event.

declare
	v_row				record;
	v_new_event			bigint;
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;

	update sl_node set no_failed=true  where no_id = ANY 
	(p_failed_nodes) and no_failed=false;
	-- Rewrite sl_listen table
	perform RebuildListenEntries();
	-- ----
	-- Make sure the node daemon will restart
	-- ----
	raise notice 'calling restart node %',p_failed_node;

	notify "_schemadoc_Restart";

	select createEvent('_schemadoc','FAILOVER_NODE',
								p_failed_node::text,p_ev_seqno::text,
								array_to_string(p_failed_nodes,','))
			into v_new_event;
		

	return v_new_event;
end;