Content-Length: 458956 | pFad | http://github.com/postgres/postgres/commit/4464fddf7b50abe3dbb462f76fd925e10eedad1c

98 Improve runtime and output of tests for replication slots checkpointing. · postgres/postgres@4464fdd · GitHub
Skip to content

Commit 4464fdd

Browse files
committed
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. This commit modifies the mentioned tests to utilize the $node->advance_wal() function, thereby reducing runtime. Once we do not use the generated data, the proposed function is a good alternative, which 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. Also, remove excessive 'shared_preload_libraries' GUC from the config and add a check for 'injection_points' extension availability. Reported-by: Alexander Lakhin <exclusion@gmail.com> Reported-by: Tom Lane <tgl@sss.pgh.pa.us> Author: Alexander Korotkov <aekorotkov@gmail.com> Author: Vitaly Davydov <v.davydov@postgrespro.ru> Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com> Discussion: https://postgr.es/m/fbc5d94e-6fbd-4a64-85d4-c9e284a58eb2%40gmail.com Backpatch-through: 17
1 parent a8360f0 commit 4464fdd

File tree

2 files changed

+25
-29
lines changed

2 files changed

+25
-29
lines changed

src/test/recovery/t/046_checkpoint_logical_slot.pl

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@
2121

2222
$node = PostgreSQL::Test::Cluster->new('mike');
2323
$node->init;
24-
$node->append_conf('postgresql.conf',
25-
"shared_preload_libraries = 'injection_points'");
2624
$node->append_conf('postgresql.conf', "wal_level = 'logical'");
2725
$node->start;
28-
$node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
2926

30-
# Create a simple table to generate data into.
31-
$node->safe_psql('postgres',
32-
q{create table t (id serial primary key, b text)});
27+
# Check if the extension injection_points is available, as it may be
28+
# possible that this script is run with installcheck, where the module
29+
# would not be installed by default.
30+
if (!$node->check_extension('injection_points'))
31+
{
32+
plan skip_all => 'Extension injection_points not installed';
33+
}
34+
35+
$node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
3336

3437
# Create the two slots we'll need.
3538
$node->safe_psql('postgres',
@@ -58,23 +61,17 @@
5861
\q
5962
));
6063

61-
# Insert 2M rows; that's about 260MB (~20 segments) worth of WAL.
62-
$node->safe_psql('postgres',
63-
q{insert into t (b) select md5(i::text) from generate_series(1,1000000) s(i)}
64-
);
64+
$node->advance_wal(20);
6565

6666
# Run another checkpoint to set a new restore LSN.
6767
$node->safe_psql('postgres', q{checkpoint});
6868

69-
# Another 2M rows; that's about 260MB (~20 segments) worth of WAL.
70-
$node->safe_psql('postgres',
71-
q{insert into t (b) select md5(i::text) from generate_series(1,1000000) s(i)}
72-
);
69+
$node->advance_wal(20);
7370

7471
# Run another checkpoint, this time in the background, and make it wait
7572
# on the injection point) so that the checkpoint stops right before
7673
# removing old WAL segments.
77-
note('starting checkpoint\n');
74+
note('starting checkpoint');
7875

7976
my $checkpoint = $node->background_psql('postgres');
8077
$checkpoint->query_safe(
@@ -88,7 +85,7 @@
8885
));
8986

9087
# Wait until the checkpoint stops right before removing WAL segments.
91-
note('waiting for injection_point\n');
88+
note('waiting for injection_point');
9289
$node->wait_for_event('checkpointer', 'checkpoint-before-old-wal-removal');
9390
note('injection_point is reached');
9491

@@ -107,7 +104,7 @@
107104
));
108105

109106
# Wait until the slot's restart_lsn points to the next WAL segment.
110-
note('waiting for injection_point\n');
107+
note('waiting for injection_point');
111108
$node->wait_for_event('client backend',
112109
'logical-replication-slot-advance-segment');
113110
note('injection_point is reached');

src/test/recovery/t/047_checkpoint_physical_slot.pl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@
2121

2222
$node = PostgreSQL::Test::Cluster->new('mike');
2323
$node->init;
24-
$node->append_conf('postgresql.conf',
25-
"shared_preload_libraries = 'injection_points'");
2624
$node->append_conf('postgresql.conf', "wal_level = 'replica'");
2725
$node->start;
28-
$node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
2926

30-
# Create a simple table to generate data into.
31-
$node->safe_psql('postgres',
32-
q{create table t (id serial primary key, b text)});
27+
# Check if the extension injection_points is available, as it may be
28+
# possible that this script is run with installcheck, where the module
29+
# would not be installed by default.
30+
if (!$node->check_extension('injection_points'))
31+
{
32+
plan skip_all => 'Extension injection_points not installed';
33+
}
34+
35+
$node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
3336

3437
# Create a physical replication slot.
3538
$node->safe_psql('postgres',
@@ -44,9 +47,7 @@
4447
$node->safe_psql('postgres', q{checkpoint});
4548

4649
# Insert 2M rows; that's about 260MB (~20 segments) worth of WAL.
47-
$node->safe_psql('postgres',
48-
q{insert into t (b) select md5(i::text) from generate_series(1,100000) s(i)}
49-
);
50+
$node->advance_wal(20);
5051

5152
# Advance slot to the current position, just to have everything "valid".
5253
$node->safe_psql('postgres',
@@ -57,9 +58,7 @@
5758
$node->safe_psql('postgres', q{checkpoint});
5859

5960
# Another 2M rows; that's about 260MB (~20 segments) worth of WAL.
60-
$node->safe_psql('postgres',
61-
q{insert into t (b) select md5(i::text) from generate_series(1,1000000) s(i)}
62-
);
61+
$node->advance_wal(20);
6362

6463
my $restart_lsn_init = $node->safe_psql('postgres',
6564
q{select restart_lsn from pg_replication_slots where slot_name = 'slot_physical'}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgres/postgres/commit/4464fddf7b50abe3dbb462f76fd925e10eedad1c

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy