Content-Length: 470311 | pFad | http://github.com/postgres/postgres/commit/5ed50f9386f04d9b8a88af8902b06cb747db7b54

BD Improve runtime and output of tests for replication slots checkpointing. · postgres/postgres@5ed50f9 · GitHub
Skip to content

Commit 5ed50f9

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 0f5ac7f commit 5ed50f9

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,21 @@
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+
$result = $node->safe_psql('postgres',
31+
"SELECT count(*) > 0 FROM pg_available_extensions WHERE name = 'injection_points';"
32+
);
33+
if ($result eq 'f')
34+
{
35+
plan skip_all => 'Extension injection_points not installed';
36+
}
37+
38+
$node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
3339

3440
# Create the two slots we'll need.
3541
$node->safe_psql('postgres',
@@ -58,23 +64,17 @@
5864
\q
5965
));
6066

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-
);
67+
$node->advance_wal(20);
6568

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

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-
);
72+
$node->advance_wal(20);
7373

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

7979
my $checkpoint = $node->background_psql('postgres');
8080
$checkpoint->query_safe(
@@ -88,7 +88,7 @@
8888
));
8989

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

@@ -107,7 +107,7 @@
107107
));
108108

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

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,21 @@
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+
$result = $node->safe_psql('postgres',
31+
"SELECT count(*) > 0 FROM pg_available_extensions WHERE name = 'injection_points';"
32+
);
33+
if ($result eq 'f')
34+
{
35+
plan skip_all => 'Extension injection_points not installed';
36+
}
37+
38+
$node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
3339

3440
# Create a physical replication slot.
3541
$node->safe_psql('postgres',
@@ -44,9 +50,7 @@
4450
$node->safe_psql('postgres', q{checkpoint});
4551

4652
# 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-
);
53+
$node->advance_wal(20);
5054

5155
# Advance slot to the current position, just to have everything "valid".
5256
$node->safe_psql('postgres',
@@ -57,9 +61,7 @@
5761
$node->safe_psql('postgres', q{checkpoint});
5862

5963
# 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-
);
64+
$node->advance_wal(20);
6365

6466
my $restart_lsn_init = $node->safe_psql('postgres',
6567
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/5ed50f9386f04d9b8a88af8902b06cb747db7b54

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy