Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ea256a5

Browse files
committed
Fix bugs in ensure_redundancy function
1 parent 6bb42f5 commit ea256a5

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

pg_shardman--1.0.sql

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,25 +593,34 @@ DECLARE
593593
poll text;
594594
response text;
595595
BEGIN
596+
IF shardman.redirect_to_shardlord('ensure_redundancy()')
597+
THEN
598+
RETURN;
599+
END IF;
600+
601+
-- Wait until all subscritpion switch to ready state
596602
LOOP
597-
poll := ''
603+
poll := '';
598604
FOR src_node_id IN SELECT id FROM shardman.nodes
599-
LOOP
605+
LOOP
600606
FOR dst_node_id IN SELECT id FROM shardman.nodes WHERE id<>src_node_id
601-
LOOP
607+
LOOP
602608
sub_name := format('sub_%s_%s', dst_node_id, src_node_id);
603609
poll := format('%s%s:SELECT shardman.is_subscription_ready(%L);',
604610
poll, dst_node_id, sub_name);
605611
END LOOP;
606612
END LOOP;
607-
613+
614+
-- Poll subsciption statuses at all nodes
608615
response := shardman.broadcast(poll);
616+
617+
-- Check if all are ready
609618
EXIT WHEN POSITION('f' IN response)=0;
610619

611620
PERFORM pg_sleep(timeout_sec);
612621
END LOOP;
613622
END
614-
$$ LANGUAGE plpgsql;
623+
$$ LANGUAGE plpgsql;
615624

616625

617626
-- Remove table from all nodes.

0 commit comments

Comments
 (0)