diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2021-07-29 17:09:06 -0400 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2021-07-29 17:09:06 -0400 |
commit | f951f6f69c7e77acdd04776168126f00e269dcfb (patch) | |
tree | f735942d27d778c569d9467d1ad6ea86cd40e5cd /src | |
parent | c73bba23ef07f88ce3860a06bbf56180e00b185d (diff) | |
download | postgresql-f951f6f69c7e77acdd04776168126f00e269dcfb.tar.gz postgresql-f951f6f69c7e77acdd04776168126f00e269dcfb.zip |
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
d18e75664a2f.
Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/20210729.162038.534808353849568395.horikyota.ntt@gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/transam/xlog.c | 2 | ||||
-rw-r--r-- | src/test/recovery/t/019_replslot_limit.pl | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 195b840d6fa..d73a55ae175 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -9291,7 +9291,7 @@ CreateCheckPoint(int flags) if (!RecoveryInProgress()) TruncateSUBTRANS(GetOldestTransactionIdConsideredRunning()); - /* Real work is done, but log and update stats before releasing lock. */ + /* Real work is done; log and update stats. */ LogCheckpointEnd(false); /* Reset the process title */ diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl index 54ddcef2bbd..f99fa16d472 100644 --- a/src/test/recovery/t/019_replslot_limit.pl +++ b/src/test/recovery/t/019_replslot_limit.pl @@ -173,11 +173,21 @@ ok( !find_in_log( "requested WAL segment [0-9A-F]+ has already been removed"), 'check that required WAL segments are still available'); -# Advance WAL again, the slot loses the oldest segment. +# Create one checkpoint, to improve stability of the next steps +$node_primary->safe_psql('postgres', "CHECKPOINT;"); + +# Prevent other checkpoints from occurring while advancing WAL segments +$node_primary->safe_psql('postgres', + "ALTER SYSTEM SET max_wal_size='40MB'; SELECT pg_reload_conf()"); + +# Advance WAL again. The slot loses the oldest segment by the next checkpoint my $logstart = get_log_size($node_primary); advance_wal($node_primary, 7); -# wait until the WARNING is issued +# Now create another checkpoint and wait until the WARNING is issued +$node_primary->safe_psql('postgres', + 'ALTER SYSTEM RESET max_wal_size; SELECT pg_reload_conf()'); +$node_primary->safe_psql('postgres', "CHECKPOINT;"); my $invalidated = 0; for (my $i = 0; $i < 10000; $i++) { |