Skip to content

Commit ce197e9

Browse files
committed
Close yet another race condition in replication slot test code
Buildfarm shows that this test has a further failure mode when a checkpoint starts earlier than expected, so we detect a "checkpoint completed" line that's not the one we want. Change the config to try and prevent this. Per buildfarm While at it, update one comment that was forgotten in commit d18e756. Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Discussion: https://postgr.es/m/20210729.162038.534808353849568395.horikyota.ntt@gmail.com
1 parent fcf4c0a commit ce197e9

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/backend/access/transam/xlog.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9329,7 +9329,7 @@ CreateCheckPoint(int flags)
93299329
if (!RecoveryInProgress())
93309330
TruncateSUBTRANS(GetOldestTransactionIdConsideredRunning());
93319331

9332-
/* Real work is done, but log and update stats before releasing lock. */
9332+
/* Real work is done; log and update stats. */
93339333
LogCheckpointEnd(false);
93349334

93359335
/* Reset the process title */

src/test/recovery/t/019_replslot_limit.pl

+12-2
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,21 @@
173173
"requested WAL segment [0-9A-F]+ has already been removed"),
174174
'check that required WAL segments are still available');
175175

176-
# Advance WAL again, the slot loses the oldest segment.
176+
# Create one checkpoint, to improve stability of the next steps
177+
$node_primary->safe_psql('postgres', "CHECKPOINT;");
178+
179+
# Prevent other checkpoints from occurring while advancing WAL segments
180+
$node_primary->safe_psql('postgres',
181+
"ALTER SYSTEM SET max_wal_size='40MB'; SELECT pg_reload_conf()");
182+
183+
# Advance WAL again. The slot loses the oldest segment by the next checkpoint
177184
my $logstart = get_log_size($node_primary);
178185
advance_wal($node_primary, 7);
179186

180-
# wait until the WARNING is issued
187+
# Now create another checkpoint and wait until the WARNING is issued
188+
$node_primary->safe_psql('postgres',
189+
'ALTER SYSTEM RESET max_wal_size; SELECT pg_reload_conf()');
190+
$node_primary->safe_psql('postgres', "CHECKPOINT;");
181191
my $invalidated = 0;
182192
for (my $i = 0; $i < 10000; $i++)
183193
{

0 commit comments

Comments
 (0)