Skip to content

Commit f4240a7

Browse files
Zhijie HouCommitfest Bot
authored andcommitted
Stablize the tests in 035_conflicts
The test used VACUUM to remove delete column, while that might not be stable due to concurrent bgwriter or checkpoint that would lock the page where the deleted tuple exists. Since the test has already confirmed that the replication slot.xmin has advanced, which should be sufficient to prove that the feature works correctly. This commit removes these unstable VACUUM tests. Additionally, the test has a check to verify the resumption of retention for conflict-relevant information after setting max_retention_duration to 0. However, in some cases, the apply worker resumes retention immediately after the inactive slot is removed from the synchronized_standby_slots configuration, prior to setting max_retention_duration to 0. This can occur if the system applies remote changes in less than 1ms, leading to test timeouts while waiting for the resumption log at a later position. To ensure stability, this commit delays the removal of synchronized_standby_slots until after max_retention_duration has been set to 0.
1 parent 66dabc0 commit f4240a7

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

src/test/subscription/t/035_conflicts.pl

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,6 @@
342342
),
343343
"the xmin value of slot 'pg_conflict_detection' is updated on Node A");
344344

345-
# Confirm that the dead tuple can be removed now
346-
($cmdret, $stdout, $stderr) = $node_A->psql(
347-
'postgres', qq(VACUUM (verbose) public.tab;)
348-
);
349-
350-
ok( $stderr =~
351-
qr/1 removed, 1 remain, 0 are dead but not yet removable/,
352-
'the deleted column is removed');
353-
354345
###############################################################################
355346
# Ensure that the deleted tuple needed to detect an update_deleted conflict is
356347
# accessible via a sequential table scan.
@@ -555,13 +546,6 @@
555546
"the xmin value of slot 'pg_conflict_detection' is updated on subscriber"
556547
);
557548

558-
# Confirm that the dead tuple can be removed now
559-
($cmdret, $stdout, $stderr) =
560-
$node_A->psql('postgres', qq(VACUUM (verbose) public.tab;));
561-
562-
ok($stderr =~ qr/1 removed, 0 remain, 0 are dead but not yet removable/,
563-
'the deleted column is removed');
564-
565549
# Get the commit timestamp for the publisher's update
566550
my $pub_ts = $node_B->safe_psql('postgres',
567551
"SELECT pg_xact_commit_timestamp(xmin) from tab where a=1;");
@@ -625,12 +609,6 @@
625609
"SELECT subretentionactive FROM pg_subscription WHERE subname='$subname_AB';");
626610
is($result, qq(f), 'retention is inactive');
627611

628-
# Drop the physical slot and reset the synchronized_standby_slots setting
629-
$node_B->safe_psql('postgres',
630-
"SELECT * FROM pg_drop_replication_slot('blocker');");
631-
$node_B->adjust_conf('postgresql.conf', 'synchronized_standby_slots', "''");
632-
$node_B->reload;
633-
634612
###############################################################################
635613
# Check that dead tuple retention resumes when the max_retention_duration is set
636614
# 0.
@@ -642,6 +620,15 @@
642620
$node_A->safe_psql('postgres',
643621
"ALTER SUBSCRIPTION $subname_AB SET (max_retention_duration = 0);");
644622

623+
# Drop the physical slot and reset the synchronized_standby_slots setting. We
624+
# change this after setting max_retention_duration to 0, ensuring the apply
625+
# worker does not resume prematurely without noticing the updated
626+
# max_retention_duration value.
627+
$node_B->safe_psql('postgres',
628+
"SELECT * FROM pg_drop_replication_slot('blocker');");
629+
$node_B->adjust_conf('postgresql.conf', 'synchronized_standby_slots', "''");
630+
$node_B->reload;
631+
645632
# Confirm that the retention resumes
646633
$node_A->wait_for_log(
647634
qr/logical replication worker for subscription "tap_sub_a_b" will resume retaining the information for detecting conflicts

0 commit comments

Comments
 (0)