From 5fc8de1ad72664dd26b71ccad0e597d9c2161cbc Mon Sep 17 00:00:00 2001 From: Steve Singer Date: Mon, 27 Oct 2014 17:01:29 -0400 Subject: [PATCH] Bug 354 The RebuildListenEntries for a failed node that provides no subscriptions deletes all listen entries from that node. The remaining nodes might still need to listen for these events if the failover target has them. Otherwise the FAILOVER_NODE event will wait for this event but it will never come. Leave in the listen paths for failed nodes that don't provide any sets --- src/backend/slony1_funcs.sql | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/backend/slony1_funcs.sql b/src/backend/slony1_funcs.sql index fca3421..53d4ca0 100644 --- a/src/backend/slony1_funcs.sql +++ b/src/backend/slony1_funcs.sql @@ -4999,6 +4999,7 @@ returns int as $$ declare v_row record; + v_cnt integer; begin -- ---- -- Grab the central configuration lock @@ -5088,8 +5089,8 @@ begin end if; end if; - if v_row.failed then - + if v_row.failed then + --for every failed node we delete all sl_listen entries --except via providers (listed in sl_subscribe) --or failover candidates (sl_failover_targets) @@ -5097,7 +5098,17 @@ begin --that is more ahead of the failover candidate from --sending events to the failover candidate that --are 'too far ahead' - delete from @NAMESPACE@.sl_listen where + + --if the failed node is not an origin for any + --node then we don't delete all listen paths + --for events from it. Instead we leave + --the listen network alone. + + select count(*) into v_cnt from @NAMESPACE@.sl_subscribe sub, + @NAMESPACE@.sl_set s + where s.set_origin=v_row.origin and s.set_id=sub.sub_set; + if v_cnt > 0 then + delete from @NAMESPACE@.sl_listen where li_origin=v_row.origin and li_receiver=v_row.receiver and li_provider not in @@ -5106,7 +5117,8 @@ begin @NAMESPACE@.sl_set where sub_set=set_id and set_origin=v_row.origin); - end if; + end if; + end if; -- insert into @NAMESPACE@.sl_listen -- (li_origin,li_provider,li_receiver) -- SELECT v_row.origin, pa_server -- 1.7.10.4