Slony-I 2.2.10 Documentation | ||||
---|---|---|---|---|
Prev | Fast Backward | Chapter 8. Schema schemadoc | Fast Forward | Next |
8.63. failednode(p_failed_nodes integer, p_backup_node integer, p_failed_node integer[])
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; v_restart_required boolean; begin -- ---- -- Grab the central configuration lock -- ---- lock table sl_config_lock; v_restart_required:=false; -- -- 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); if found then v_restart_required:=true; end if; -- -- if this node is receiving a subscription from the backup node -- with a failed node as the provider we need to fix this. update sl_subscribe set sub_provider=p_backup_node from sl_set where set_id = sub_set and set_origin=p_failed_node and sub_provider = ANY(p_failed_nodes) and sub_receiver=getLocalNodeId('_schemadoc'); -- ---- -- 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 and pa_conninfo<>'<event pending>'; if found then v_restart_required:=true; end if; 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; if found then v_restart_required:=true; end if; end if; if v_restart_required then -- Rewrite sl_listen table perform RebuildListenEntries(); -- ---- -- Make sure the node daemon will restart -- ---- notify "_schemadoc_Restart"; end if; -- ---- -- That is it - so far. -- ---- return p_failed_node; end;