| Slony-I 2.2.0.b5 Documentation | ||||
|---|---|---|---|---|
| Prev | Fast Backward | Chapter 8. Schema schemadoc | Fast Forward | Next |
Function Properties
Language: PLPGSQL
Return Type: integer
Initiate failover from failed_node to backup_node. This function must be called on all nodes, and then waited for the restart of all node daemons.declare
v_row record;
v_row2 record;
v_failed boolean;
begin
--
-- any nodes other than the backup receiving
-- ANY subscription from a failed node
-- will now get that data from the backup node.
update sl_subscribe set
sub_provider=p_backup_node
where sub_provider=p_failed_node
and sub_receiver<>p_backup_node
and sub_receiver <> ALL (p_failed_nodes);
-- ----
-- Terminate all connections of the failed node the hard way
-- ----
perform terminateNodeConnections(p_failed_node);
-- Clear out the paths for the failed node.
-- This ensures that *this* node won't be pulling data from
-- the failed node even if it *does* become accessible
update sl_path set pa_conninfo='<event pending>' WHERE
pa_server=p_failed_node;
v_failed := exists (select 1 from sl_node
where no_failed=true and no_id=p_failed_node);
if not v_failed then
update sl_node set no_failed=true where no_id = ANY (p_failed_nodes)
and no_failed=false;
end if;
-- Rewrite sl_listen table
perform RebuildListenEntries();
-- ----
-- Make sure the node daemon will restart
-- ----
notify "_schemadoc_Restart";
-- ----
-- That is it - so far.
-- ----
return p_failed_node;
end;