Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd680992

Browse files
committed
Speed up TAP tests of pg_receivewal
This commit improves the speed of those tests by 25~30%, using somesimple ideas to reduce the amount of data written by pg_receivewal:- Use a segment size of 1MB. While reducing the amount of data zeroedby pg_receivewal for the new segments, this improves the code coveragewith a non-default segment size.- In the last test involving a slot's restart_lsn, generate a checkpointto advance the redo LSN and the WAL retained by the slot created,reducing the number of segments that need to be archived. This countsfor most of the gain.- Minimize the amount of data inserted into the dummy table.Reviewed-by: Ronan DunklauDiscussion:https://postgr.es/m/YXqYKAdVEqmyTltK@paquier.xyz
1 parent3c17926 commitd680992

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

‎src/bin/pg_basebackup/t/020_pg_receivewal.pl

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
umask(0077);
1616

1717
my$primary = PostgreSQL::Test::Cluster->new('primary');
18-
$primary->init(allows_streaming=> 1);
18+
$primary->init(allows_streaming=> 1,extra=> ['--wal-segsize=1']);
1919
$primary->start;
2020

2121
my$stream_dir =$primary->basedir .'/archive_wal';
@@ -50,13 +50,12 @@
5050
# Generate some WAL. Use --synchronous at the same time to add more
5151
# code coverage. Switch to the next segment first so that subsequent
5252
# restarts of pg_receivewal will see this segment as full..
53-
$primary->psql('postgres','CREATE TABLE test_table(x integer);');
53+
$primary->psql('postgres','CREATE TABLE test_table(x integer PRIMARY KEY);');
5454
$primary->psql('postgres','SELECT pg_switch_wal();');
5555
my$nextlsn =
5656
$primary->safe_psql('postgres','SELECT pg_current_wal_insert_lsn();');
5757
chomp($nextlsn);
58-
$primary->psql('postgres',
59-
'INSERT INTO test_table VALUES (generate_series(1,100));');
58+
$primary->psql('postgres','INSERT INTO test_table VALUES (1);');
6059

6160
# Stream up to the given position. This is necessary to have a fixed
6261
# started point for the next commands done in this test, with or without
@@ -85,8 +84,7 @@
8584
$nextlsn =
8685
$primary->safe_psql('postgres','SELECT pg_current_wal_insert_lsn();');
8786
chomp($nextlsn);
88-
$primary->psql('postgres',
89-
'INSERT INTO test_table VALUES (generate_series(100,200));');
87+
$primary->psql('postgres','INSERT INTO test_table VALUES (2);');
9088

9189
# Note the trailing whitespace after the value of --compress, that is
9290
# a valid value.
@@ -136,8 +134,7 @@
136134
$nextlsn =
137135
$primary->safe_psql('postgres','SELECT pg_current_wal_insert_lsn();');
138136
chomp($nextlsn);
139-
$primary->psql('postgres',
140-
'INSERT INTO test_table VALUES (generate_series(200,300));');
137+
$primary->psql('postgres','INSERT INTO test_table VALUES (3);');
141138
$primary->command_ok(
142139
[
143140
'pg_receivewal','-D',$stream_dir,'--verbose',
@@ -167,7 +164,9 @@
167164
$slot_name ='archive_slot';
168165

169166
# Setup the slot, reserving WAL at creation (corresponding to the
170-
# last redo LSN here, actually).
167+
# last redo LSN here, actually, so use a checkpoint to reduce the
168+
# number of segments archived).
169+
$primary->psql('postgres','checkpoint;');
171170
$primary->psql('postgres',
172171
"SELECT pg_create_physical_replication_slot('$slot_name', true);");
173172

@@ -181,13 +180,16 @@
181180

182181
# Switch to a new segment, to make sure that the segment retained by the
183182
# slot is still streamed. This may not be necessary, but play it safe.
184-
$primary->psql('postgres',
185-
'INSERT INTO test_table VALUES (generate_series(1,100));');
183+
$primary->psql('postgres','INSERT INTO test_table VALUES (4);');
186184
$primary->psql('postgres','SELECT pg_switch_wal();');
187185
$nextlsn =
188186
$primary->safe_psql('postgres','SELECT pg_current_wal_insert_lsn();');
189187
chomp($nextlsn);
190188

189+
# Add a bit more data to accelerate the end of the next pg_receivewal
190+
# commands.
191+
$primary->psql('postgres','INSERT INTO test_table VALUES (5);');
192+
191193
# Check case where the slot does not exist.
192194
$primary->command_fails_like(
193195
[

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp