Skip to content

Commit 3820c63

Browse files
committed
Run most pg_dump and pg_dumpall tests with --no-sync
Commit 96a7128 made pg_dump and pg_dumpall sync their output by default. However, there's no great need for that in testing, and it could impose a performance penalty, so we add the --no-sync flag to most of the test cases. Michael Paquier
1 parent 521fd47 commit 3820c63

File tree

4 files changed

+136
-57
lines changed

4 files changed

+136
-57
lines changed

src/bin/pg_dump/t/002_pg_dump.pl

+71-25
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
binary_upgrade => {
4040
dump_cmd => [
4141
'pg_dump',
42+
'--no-sync',
4243
'--format=custom',
4344
"--file=$tempdir/binary_upgrade.dump",
4445
'-w',
@@ -55,6 +56,7 @@
5556
clean => {
5657
dump_cmd => [
5758
'pg_dump',
59+
'--no-sync',
5860
"--file=$tempdir/clean.sql",
5961
'--include-subscriptions',
6062
'-c',
@@ -63,6 +65,7 @@
6365
clean_if_exists => {
6466
dump_cmd => [
6567
'pg_dump',
68+
'--no-sync',
6669
"--file=$tempdir/clean_if_exists.sql",
6770
'--include-subscriptions',
6871
'-c',
@@ -71,12 +74,16 @@
7174
'postgres', ], },
7275
column_inserts => {
7376
dump_cmd => [
74-
'pg_dump', "--file=$tempdir/column_inserts.sql",
75-
'-a', '--column-inserts',
77+
'pg_dump',
78+
'--no-sync',
79+
"--file=$tempdir/column_inserts.sql",
80+
'-a',
81+
'--column-inserts',
7682
'postgres', ], },
7783
createdb => {
7884
dump_cmd => [
7985
'pg_dump',
86+
'--no-sync',
8087
"--file=$tempdir/createdb.sql",
8188
'--include-subscriptions',
8289
'-C',
@@ -86,6 +93,7 @@
8693
data_only => {
8794
dump_cmd => [
8895
'pg_dump',
96+
'--no-sync',
8997
"--file=$tempdir/data_only.sql",
9098
'--include-subscriptions',
9199
'-a',
@@ -94,8 +102,13 @@
94102
'-v', # no-op, just make sure it works
95103
'postgres', ], },
96104
defaults => {
97-
dump_cmd => [ 'pg_dump', '-f', "$tempdir/defaults.sql", 'postgres', ],
98-
},
105+
dump_cmd => [
106+
'pg_dump',
107+
'--no-sync',
108+
'-f',
109+
"$tempdir/defaults.sql",
110+
'postgres', ], },
111+
# Do not use --no-sync to give test coverage for data sync.
99112
defaults_custom_format => {
100113
test_key => 'defaults',
101114
dump_cmd => [
@@ -105,6 +118,7 @@
105118
'pg_restore', '-Fc',
106119
"--file=$tempdir/defaults_custom_format.sql",
107120
"$tempdir/defaults_custom_format.dump", ], },
121+
# Do not use --no-sync to give test coverage for data sync.
108122
defaults_dir_format => {
109123
test_key => 'defaults',
110124
dump_cmd => [
@@ -114,6 +128,7 @@
114128
'pg_restore', '-Fd',
115129
"--file=$tempdir/defaults_dir_format.sql",
116130
"$tempdir/defaults_dir_format", ], },
131+
# Do not use --no-sync to give test coverage for data sync.
117132
defaults_parallel => {
118133
test_key => 'defaults',
119134
dump_cmd => [
@@ -123,6 +138,7 @@
123138
'pg_restore',
124139
"--file=$tempdir/defaults_parallel.sql",
125140
"$tempdir/defaults_parallel", ], },
141+
# Do not use --no-sync to give test coverage for data sync.
126142
defaults_tar_format => {
127143
test_key => 'defaults',
128144
dump_cmd => [
@@ -135,55 +151,83 @@
135151
"$tempdir/defaults_tar_format.tar", ], },
136152
exclude_dump_test_schema => {
137153
dump_cmd => [
138-
'pg_dump', "--file=$tempdir/exclude_dump_test_schema.sql",
139-
'--exclude-schema=dump_test', 'postgres', ], },
154+
'pg_dump',
155+
'--no-sync',
156+
"--file=$tempdir/exclude_dump_test_schema.sql",
157+
'--exclude-schema=dump_test',
158+
'postgres', ], },
140159
exclude_test_table => {
141160
dump_cmd => [
142161
'pg_dump',
162+
'--no-sync',
143163
"--file=$tempdir/exclude_test_table.sql",
144164
'--exclude-table=dump_test.test_table',
145165
'postgres', ], },
146166
exclude_test_table_data => {
147167
dump_cmd => [
148168
'pg_dump',
169+
'--no-sync',
149170
"--file=$tempdir/exclude_test_table_data.sql",
150171
'--exclude-table-data=dump_test.test_table',
151172
'--no-unlogged-table-data',
152173
'postgres', ], },
153174
pg_dumpall_globals => {
154175
dump_cmd => [
155176
'pg_dumpall', '-v',
156-
"--file=$tempdir/pg_dumpall_globals.sql", '-g', ], },
177+
"--file=$tempdir/pg_dumpall_globals.sql", '-g',
178+
'--no-sync', ], },
157179
pg_dumpall_globals_clean => {
158180
dump_cmd => [
159-
'pg_dumpall', "--file=$tempdir/pg_dumpall_globals_clean.sql",
160-
'-g', '-c', ], },
181+
'pg_dumpall',
182+
"--file=$tempdir/pg_dumpall_globals_clean.sql",
183+
'-g',
184+
'-c',
185+
'--no-sync', ], },
161186
pg_dumpall_dbprivs => {
162-
dump_cmd =>
163-
[ 'pg_dumpall', "--file=$tempdir/pg_dumpall_dbprivs.sql", ], },
187+
dump_cmd => [
188+
'pg_dumpall',
189+
'--no-sync',
190+
"--file=$tempdir/pg_dumpall_dbprivs.sql", ], },
164191
no_blobs => {
165-
dump_cmd =>
166-
[ 'pg_dump', "--file=$tempdir/no_blobs.sql", '-B', 'postgres', ], },
192+
dump_cmd => [
193+
'pg_dump',
194+
'--no-sync',
195+
"--file=$tempdir/no_blobs.sql",
196+
'-B',
197+
'postgres', ], },
167198
no_privs => {
168-
dump_cmd =>
169-
[ 'pg_dump', "--file=$tempdir/no_privs.sql", '-x', 'postgres', ], },
199+
dump_cmd => [
200+
'pg_dump',
201+
'--no-sync',
202+
"--file=$tempdir/no_privs.sql",
203+
'-x',
204+
'postgres', ], },
170205
no_owner => {
171-
dump_cmd =>
172-
[ 'pg_dump', "--file=$tempdir/no_owner.sql", '-O', 'postgres', ], },
206+
dump_cmd => [
207+
'pg_dump',
208+
'--no-sync',
209+
"--file=$tempdir/no_owner.sql",
210+
'-O',
211+
'postgres', ], },
173212
only_dump_test_schema => {
174213
dump_cmd => [
175-
'pg_dump', "--file=$tempdir/only_dump_test_schema.sql",
176-
'--schema=dump_test', 'postgres', ], },
214+
'pg_dump',
215+
'--no-sync',
216+
"--file=$tempdir/only_dump_test_schema.sql",
217+
'--schema=dump_test',
218+
'postgres', ], },
177219
only_dump_test_table => {
178220
dump_cmd => [
179221
'pg_dump',
222+
'--no-sync',
180223
"--file=$tempdir/only_dump_test_table.sql",
181224
'--table=dump_test.test_table',
182225
'--lock-wait-timeout=1000000',
183226
'postgres', ], },
184227
role => {
185228
dump_cmd => [
186229
'pg_dump',
230+
'--no-sync',
187231
"--file=$tempdir/role.sql",
188232
'--role=regress_dump_test_role',
189233
'--schema=dump_test_second_schema',
@@ -192,6 +236,7 @@
192236
test_key => 'role',
193237
dump_cmd => [
194238
'pg_dump',
239+
'--no-sync',
195240
'--format=directory',
196241
'--jobs=2',
197242
"--file=$tempdir/role_parallel",
@@ -204,28 +249,29 @@
204249
schema_only => {
205250
dump_cmd => [
206251
'pg_dump', '--format=plain', "--file=$tempdir/schema_only.sql",
207-
'-s', 'postgres', ], },
252+
'--no-sync', '-s', 'postgres', ], },
208253
section_pre_data => {
209254
dump_cmd => [
210255
'pg_dump', "--file=$tempdir/section_pre_data.sql",
211256
'--include-subscriptions',
212-
'--section=pre-data', 'postgres', ], },
257+
'--section=pre-data', '--no-sync', 'postgres', ], },
213258
section_data => {
214259
dump_cmd => [
215260
'pg_dump', "--file=$tempdir/section_data.sql",
216-
'--section=data', 'postgres', ], },
261+
'--section=data', '--no-sync', 'postgres', ], },
217262
section_post_data => {
218263
dump_cmd => [
219264
'pg_dump', "--file=$tempdir/section_post_data.sql",
220-
'--section=post-data', 'postgres', ], },
265+
'--section=post-data', '--no-sync', 'postgres', ], },
221266
test_schema_plus_blobs => {
222267
dump_cmd => [
223268
'pg_dump', "--file=$tempdir/test_schema_plus_blobs.sql",
224-
'--schema=dump_test', '-b', '-B', 'postgres', ], },
269+
270+
'--schema=dump_test', '-b', '-B', '--no-sync', 'postgres', ], },
225271
with_oids => {
226272
dump_cmd => [
227273
'pg_dump', '--oids',
228-
'--include-subscriptions',
274+
'--include-subscriptions', '--no-sync',
229275
"--file=$tempdir/with_oids.sql", 'postgres', ], },);
230276

231277
###############################################################

src/bin/pg_dump/t/010_dump_connstr.pl

+7-7
Original file line numberDiff line numberDiff line change
@@ -59,29 +59,29 @@
5959
'-U', $dbname4 ],
6060
'pg_dumpall with long ASCII name 1');
6161
$node->command_ok(
62-
[ 'pg_dumpall', '-r', '-f', $discard, '--dbname',
62+
[ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname',
6363
$node->connstr($dbname2),
6464
'-U', $dbname3 ],
6565
'pg_dumpall with long ASCII name 2');
6666
$node->command_ok(
67-
[ 'pg_dumpall', '-r', '-f', $discard, '--dbname',
67+
[ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname',
6868
$node->connstr($dbname3),
6969
'-U', $dbname2 ],
7070
'pg_dumpall with long ASCII name 3');
7171
$node->command_ok(
72-
[ 'pg_dumpall', '-r', '-f', $discard, '--dbname',
72+
[ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname',
7373
$node->connstr($dbname4),
7474
'-U', $dbname1 ],
7575
'pg_dumpall with long ASCII name 4');
7676
$node->command_ok(
77-
[ 'pg_dumpall', '-r', '-l', 'dbname=template1' ],
77+
[ 'pg_dumpall', '--no-sync', '-r', '-l', 'dbname=template1' ],
7878
'pg_dumpall -l accepts connection string');
7979

8080
$node->run_log([ 'createdb', "foo\n\rbar" ]);
8181

8282
# not sufficient to use -r here
8383
$node->command_fails(
84-
[ 'pg_dumpall', '-f', $discard ],
84+
[ 'pg_dumpall', '--no-sync', '-f', $discard ],
8585
'pg_dumpall with \n\r in database name');
8686
$node->run_log([ 'dropdb', "foo\n\rbar" ]);
8787

@@ -91,7 +91,7 @@
9191

9292
# XXX no printed message when this fails, just SIGPIPE termination
9393
$node->command_ok(
94-
[ 'pg_dump', '-Fd', '-j2', '-f', $dirfmt,
94+
[ 'pg_dump', '-Fd', '--no-sync', '-j2', '-f', $dirfmt,
9595
'-U', $dbname1, $node->connstr($dbname1) ],
9696
'parallel dump');
9797

@@ -112,7 +112,7 @@
112112
'parallel restore with create');
113113

114114

115-
$node->command_ok([ 'pg_dumpall', '-f', $plain, '-U', $dbname1 ],
115+
$node->command_ok([ 'pg_dumpall', '--no-sync', '-f', $plain, '-U', $dbname1 ],
116116
'take full dump');
117117
system_log('cat', $plain);
118118
my ($stderr, $result);

src/bin/pg_upgrade/test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ createdb "$dbname2" || createdb_status=$?
170170
createdb "$dbname3" || createdb_status=$?
171171

172172
if "$MAKE" -C "$oldsrc" installcheck; then
173-
pg_dumpall -f "$temp_root"/dump1.sql || pg_dumpall1_status=$?
173+
pg_dumpall --no-sync -f "$temp_root"/dump1.sql || pg_dumpall1_status=$?
174174
if [ "$newsrc" != "$oldsrc" ]; then
175175
oldpgversion=`psql -X -A -t -d regression -c "SHOW server_version_num"`
176176
fix_sql=""
@@ -221,7 +221,7 @@ case $testhost in
221221
*) sh ./analyze_new_cluster.sh ;;
222222
esac
223223

224-
pg_dumpall -f "$temp_root"/dump2.sql || pg_dumpall2_status=$?
224+
pg_dumpall --no-sync -f "$temp_root"/dump2.sql || pg_dumpall2_status=$?
225225
pg_ctl -m fast stop
226226

227227
# no need to echo commands anymore

0 commit comments

Comments
 (0)