From 5e332ece97a6aefcec569af7e16a4251fc79071c Mon Sep 17 00:00:00 2001 From: Alexander Korotkov Date: Sun, 15 Jun 2025 13:54:09 +0300 Subject: [PATCH v2] Improve runtime and output of tests for replication slots checkpointing. The TAP tests that verify logical and physical replication slot behavior during checkpoints (046_checkpoint_logical_slot.pl and 047_checkpoint_physical_slot.pl) inserted two batches of 2 million rows each, generating approximately 520 MB of WAL. On slow machines, or when compiled with '-DRELCACHE_FORCE_RELEASE -DCATCACHE_FORCE_RELEASE', this caused the tests to run for 8-9 minutes and occasionally time out, as seen on the buildfarm animal prion. Reduce each INSERT to 50k rows of wider data, which yields approximately 5 segments of WAL. This volume is still sufficient to advance the slot to the next segment and exercise the code paths under test, but it cuts the total wall-clock run time. While here, remove superfluous '\n' characters from several note() calls; these appeared literally in the build-farm logs and looked odd. Reported-by: Alexander Lakhin Reported-by: Tom Lane Discussion: https://postgr.es/m/fbc5d94e-6fbd-4a64-85d4-c9e284a58eb2%40gmail.com --- src/test/recovery/t/046_checkpoint_logical_slot.pl | 14 +++++++------- .../recovery/t/047_checkpoint_physical_slot.pl | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/test/recovery/t/046_checkpoint_logical_slot.pl b/src/test/recovery/t/046_checkpoint_logical_slot.pl index b4265c4a6a5..964bc34fbe8 100644 --- a/src/test/recovery/t/046_checkpoint_logical_slot.pl +++ b/src/test/recovery/t/046_checkpoint_logical_slot.pl @@ -58,23 +58,23 @@ SELECT 1 \watch 0.1 \q )); -# Insert 2M rows; that's about 260MB (~20 segments) worth of WAL. +# Insert 50K rows; that's about 86MB (~5 segments) worth of WAL. $node->safe_psql('postgres', - q{insert into t (b) select md5(i::text) from generate_series(1,1000000) s(i)} + q{insert into t (b) select repeat(md5(i::text),50) from generate_series(1,50000) s(i)} ); # Run another checkpoint to set a new restore LSN. $node->safe_psql('postgres', q{checkpoint}); -# Another 2M rows; that's about 260MB (~20 segments) worth of WAL. +# Another 50K rows; that's about 86MB (~5 segments) worth of WAL. $node->safe_psql('postgres', - q{insert into t (b) select md5(i::text) from generate_series(1,1000000) s(i)} + q{insert into t (b) select repeat(md5(i::text),50) from generate_series(1,50000) s(i)} ); # Run another checkpoint, this time in the background, and make it wait # on the injection point) so that the checkpoint stops right before # removing old WAL segments. -note('starting checkpoint\n'); +note('starting checkpoint'); my $checkpoint = $node->background_psql('postgres'); $checkpoint->query_safe( @@ -88,7 +88,7 @@ checkpoint; )); # Wait until the checkpoint stops right before removing WAL segments. -note('waiting for injection_point\n'); +note('waiting for injection_point'); $node->wait_for_event('checkpointer', 'checkpoint-before-old-wal-removal'); note('injection_point is reached'); @@ -107,7 +107,7 @@ select count(*) from pg_logical_slot_get_changes('slot_logical', null, null) \wa )); # Wait until the slot's restart_lsn points to the next WAL segment. -note('waiting for injection_point\n'); +note('waiting for injection_point'); $node->wait_for_event('client backend', 'logical-replication-slot-advance-segment'); note('injection_point is reached'); diff --git a/src/test/recovery/t/047_checkpoint_physical_slot.pl b/src/test/recovery/t/047_checkpoint_physical_slot.pl index 454e56b9bd2..3141b256bf3 100644 --- a/src/test/recovery/t/047_checkpoint_physical_slot.pl +++ b/src/test/recovery/t/047_checkpoint_physical_slot.pl @@ -43,9 +43,9 @@ $node->safe_psql('postgres', # Run checkpoint to flush current state to disk and set a baseline. $node->safe_psql('postgres', q{checkpoint}); -# Insert 2M rows; that's about 260MB (~20 segments) worth of WAL. +# Insert 50K rows; that's about 86MB (~5 segments) worth of WAL. $node->safe_psql('postgres', - q{insert into t (b) select md5(i::text) from generate_series(1,100000) s(i)} + q{insert into t (b) select repeat(md5(i::text),50) from generate_series(1,50000) s(i)} ); # Advance slot to the current position, just to have everything "valid". @@ -56,9 +56,9 @@ $node->safe_psql('postgres', # Run another checkpoint to set a new restore LSN. $node->safe_psql('postgres', q{checkpoint}); -# Another 2M rows; that's about 260MB (~20 segments) worth of WAL. +# Another 50K rows; that's about 86MB (~5 segments) worth of WAL. $node->safe_psql('postgres', - q{insert into t (b) select md5(i::text) from generate_series(1,1000000) s(i)} + q{insert into t (b) select repeat(md5(i::text),50) from generate_series(1,50000) s(i)} ); my $restart_lsn_init = $node->safe_psql('postgres', -- 2.39.5 (Apple Git-154)