diff --git a/src/test/subscription/t/026_stats.pl b/src/test/subscription/t/026_stats.pl index 0df31a6..d9589f0 100644 --- a/src/test/subscription/t/026_stats.pl +++ b/src/test/subscription/t/026_stats.pl @@ -134,24 +134,37 @@ sub create_sub_pub_w_errors or die qq(Timed out while waiting for update_exists conflict for subscription '$sub_name'); - # Truncate the test table to ensure that the conflicting update operations - # are skipped, allowing the test to continue. - $node_subscriber->safe_psql($db, qq(TRUNCATE $table_name)); + # Truncate the subscriber side test table. Now that the table is empty, + # the update conflict ('update_existing') ERRORs will stop happening. A + # single update conflict 'update_missing' will be reported, but the update + # will be skipped on the subscriber, allowing the test to continue. + $node_subscriber->safe_psql($db, qq(TRUNCATE $table_name)); + + # Wait for the subscriber to report update_missing conflict. + $node_subscriber->poll_query_until( + $db, + qq[ + SELECT update_missing_count > 0 + FROM pg_stat_subscription_stats + WHERE subname = '$sub_name' + ]) + or die + qq(Timed out while waiting for update_missing conflict for subscription '$sub_name'); # Delete data from the test table on the publisher. This delete operation # should be skipped on the subscriber since the table is already empty. $node_publisher->safe_psql($db, qq(DELETE FROM $table_name;)); - # Wait for the subscriber to report tuple missing conflict. + # Wait for the subscriber to report delete_missing conflict. $node_subscriber->poll_query_until( $db, qq[ - SELECT update_missing_count > 0 AND delete_missing_count > 0 + SELECT delete_missing_count > 0 FROM pg_stat_subscription_stats WHERE subname = '$sub_name' ]) or die - qq(Timed out while waiting for tuple missing conflict for subscription '$sub_name'); + qq(Timed out while waiting for delete_missing conflict for subscription '$sub_name'); # Prepare data for further tests. $node_publisher->safe_psql($db, qq(INSERT INTO $table_name VALUES (1))); @@ -216,7 +229,7 @@ my ($pub1_name, $sub1_name) = create_sub_pub_w_errors($node_publisher, $node_subscriber, $db, $table1_name); -# Apply errors, sync errors, and conflicts are > 0 and reset timestamp is NULL +# Apply errors, sync errors, and conflicts are > 0 and stats_reset timestamp is NULL is( $node_subscriber->safe_psql( $db, qq(SELECT apply_error_count > 0, @@ -240,7 +253,7 @@ $node_subscriber->safe_psql($db, qq(SELECT pg_stat_reset_subscription_stats((SELECT subid FROM pg_stat_subscription_stats WHERE subname = '$sub1_name'))) ); -# Apply errors, sync errors, and conflicts are 0 and stats reset is not NULL +# Apply errors, sync errors, and conflicts are 0 and stats_reset timestamp is not NULL is( $node_subscriber->safe_psql( $db, qq(SELECT apply_error_count = 0, @@ -286,7 +299,7 @@ my ($pub2_name, $sub2_name) = create_sub_pub_w_errors($node_publisher, $node_subscriber, $db, $table2_name); -# Apply errors, sync errors, and conflicts are > 0 and reset timestamp is NULL +# Apply errors, sync errors, and conflicts are > 0 and stats_reset timestamp is NULL is( $node_subscriber->safe_psql( $db, qq(SELECT apply_error_count > 0, @@ -309,7 +322,7 @@ is( $node_subscriber->safe_psql( $node_subscriber->safe_psql($db, qq(SELECT pg_stat_reset_subscription_stats(NULL))); -# Apply errors, sync errors, and conflicts are 0 and stats reset is not NULL +# Apply errors, sync errors, and conflicts are 0 and stats_reset timestamp is not NULL is( $node_subscriber->safe_psql( $db, qq(SELECT apply_error_count = 0,