@@ -2648,6 +2648,50 @@ sub wait_for_slot_catchup
2648
2648
2649
2649
=pod
2650
2650
2651
+ =item $node->wait_for_subscription_sync(publisher, subname, dbname)
2652
+
2653
+ Wait for all tables in pg_subscription_rel to complete the initial
2654
+ synchronization (i.e to be either in 'syncdone' or 'ready' state).
2655
+
2656
+ If the publisher node is given, additionally, check if the subscriber has
2657
+ caught up to what has been committed on the primary. This is useful to
2658
+ ensure that the initial data synchronization has been completed after
2659
+ creating a new subscription.
2660
+
2661
+ If there is no active replication connection from this peer, wait until
2662
+ poll_query_until timeout.
2663
+
2664
+ This is not a test. It die()s on failure.
2665
+
2666
+ =cut
2667
+
2668
+ sub wait_for_subscription_sync
2669
+ {
2670
+ my ($self , $publisher , $subname , $dbname ) = @_ ;
2671
+ my $name = $self -> name;
2672
+
2673
+ $dbname = defined ($dbname ) ? $dbname : ' postgres' ;
2674
+
2675
+ # Wait for all tables to finish initial sync.
2676
+ print " Waiting for all subscriptions in \" $name \" to synchronize data\n " ;
2677
+ my $query =
2678
+ qq[ SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');] ;
2679
+ $self -> poll_query_until($dbname , $query )
2680
+ or croak " timed out waiting for subscriber to synchronize data" ;
2681
+
2682
+ # Then, wait for the replication to catchup if required.
2683
+ if (defined ($publisher ))
2684
+ {
2685
+ croak ' subscription name must be specified' unless defined ($subname );
2686
+ $publisher -> wait_for_catchup($subname );
2687
+ }
2688
+
2689
+ print " done\n " ;
2690
+ return ;
2691
+ }
2692
+
2693
+ =pod
2694
+
2651
2695
=item $node->wait_for_log(regexp, offset)
2652
2696
2653
2697
Waits for the contents of the server log file, starting at the given offset, to
0 commit comments