diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test/recovery/t/035_standby_logical_decoding.pl index c31cab06f1c..edd8009fbce 100644 --- a/src/test/recovery/t/035_standby_logical_decoding.pl +++ b/src/test/recovery/t/035_standby_logical_decoding.pl @@ -258,10 +258,20 @@ sub wait_until_vacuum_can_remove # Launch our sql. $node_primary->safe_psql('testdb', qq[$sql]); + $node_primary->safe_psql('testdb',"CHECKPOINT"); + sleep(20); + + $node_primary->safe_psql( + 'testdb', " + BEGIN; + PREPARE TRANSACTION 'prevent_slot_advance_v1'; + INSERT INTO prevent_slot_advance VALUES (1);" + ); + # Wait until we get a newer horizon. - $node_primary->poll_query_until('testdb', - "SELECT (select pg_snapshot_xmin(pg_current_snapshot())::text::int - $xid_horizon) > 0" - ) or die "new snapshot does not have a newer horizon"; + #$node_primary->poll_query_until('testdb', + # "SELECT (select pg_snapshot_xmin(pg_current_snapshot())::text::int - $xid_horizon) > 0" + #) or die "new snapshot does not have a newer horizon"; # Launch the vacuum command and insert into flush_wal (see CREATE # TABLE flush_wal for the reason). @@ -281,7 +291,9 @@ wal_level = 'logical' max_replication_slots = 4 max_wal_senders = 4 autovacuum = off +max_prepared_transactions = 10 }); + $node_primary->dump_info; $node_primary->start; @@ -305,6 +317,7 @@ $node_primary->backup($backup_name); # Some tests need to wait for VACUUM to be replayed. But vacuum does not flush # WAL. An insert into flush_wal outside transaction does guarantee a flush. $node_primary->psql('testdb', q[CREATE TABLE flush_wal();]); +$node_primary->psql('testdb', q[CREATE TABLE prevent_slot_advance(a int);]); ####################### # Initialize standby node @@ -565,6 +578,8 @@ check_for_invalidation('vacuum_full_', 1, 'with vacuum FULL on pg_class'); # Verify reason for conflict is 'rows_removed' in pg_replication_slots check_slots_conflict_reason('vacuum_full_', 'rows_removed'); +$node_primary->safe_psql('testdb', "COMMIT PREPARED 'prevent_slot_advance_v1'"); + # Attempting to alter an invalidated slot should result in an error ($result, $stdout, $stderr) = $node_standby->psql( 'postgres', @@ -664,6 +679,8 @@ check_for_invalidation('row_removal_', $logstart, 'with vacuum on pg_class'); # Verify reason for conflict is 'rows_removed' in pg_replication_slots check_slots_conflict_reason('row_removal_', 'rows_removed'); +$node_primary->safe_psql('testdb', "COMMIT PREPARED 'prevent_slot_advance_v1'"); + $handle = make_slot_active($node_standby, 'row_removal_', 0, \$stdout, \$stderr); @@ -699,6 +716,8 @@ check_for_invalidation('shared_row_removal_', $logstart, # Verify reason for conflict is 'rows_removed' in pg_replication_slots check_slots_conflict_reason('shared_row_removal_', 'rows_removed'); +$node_primary->safe_psql('testdb', "COMMIT PREPARED 'prevent_slot_advance_v1'"); + $handle = make_slot_active($node_standby, 'shared_row_removal_', 0, \$stdout, \$stderr); @@ -737,6 +756,8 @@ ok( !$node_standby->log_contains( 'activeslot slot invalidation is not logged with vacuum on conflict_test' ); +$node_primary->safe_psql('testdb', "COMMIT PREPARED 'prevent_slot_advance_v1'"); + # Verify that pg_stat_database_conflicts.confl_active_logicalslot has not been updated ok( $node_standby->poll_query_until( 'postgres',