@@ -83,10 +83,9 @@ sub get_dump_for_comparison
83
83
open (my $dh , ' >' , $dump_adjusted )
84
84
|| die " could not open $dump_adjusted for writing $! " ;
85
85
86
- # Don't dump statistics, because there are still some bugs.
87
86
$node -> run_log(
88
87
[
89
- ' pg_dump' , ' --no-sync' , ' --no-statistics ' ,
88
+ ' pg_dump' , ' --no-sync' ,
90
89
' -d' => $node -> connstr($db ),
91
90
' -f' => $dumpfile
92
91
]);
@@ -301,64 +300,9 @@ sub get_dump_for_comparison
301
300
is($rc , 0, ' regression tests pass' );
302
301
}
303
302
304
- # Test that dump/restore of the regression database roundtrips cleanly. This
305
- # doesn't work well when the nodes are different versions, so skip it in that
306
- # case. Note that this isn't a pg_restore test, but it's convenient to do it
307
- # here because we've gone to the trouble of creating the regression database.
308
- #
309
- # Do this while the old cluster is running before it is shut down by the
310
- # upgrade test.
311
- SKIP:
312
- {
313
- my $dstnode = PostgreSQL::Test::Cluster-> new(' dst_node' );
314
-
315
- skip " different Postgres versions"
316
- if ($oldnode -> pg_version != $dstnode -> pg_version);
317
- skip " source node not using default install"
318
- if (defined $oldnode -> install_path);
319
-
320
- # Dump the original database for comparison later.
321
- my $src_dump =
322
- get_dump_for_comparison($oldnode , ' regression' , ' src_dump' , 1);
323
-
324
- # Setup destination database cluster
325
- $dstnode -> init(%old_node_params );
326
- # Stabilize stats for comparison.
327
- $dstnode -> append_conf(' postgresql.conf' , ' autovacuum = off' );
328
- $dstnode -> start;
329
-
330
- my $dump_file = " $tempdir /regression.dump" ;
331
-
332
- # Use --create in dump and restore commands so that the restored
333
- # database has the same configurable variable settings as the original
334
- # database so that the dumps taken from both databases taken do not
335
- # differ because of locale changes. Additionally this provides test
336
- # coverage for --create option.
337
- #
338
- # Use directory format so that we can use parallel dump/restore.
339
- $oldnode -> command_ok(
340
- [
341
- ' pg_dump' , ' -Fd' , ' -j2' , ' --no-sync' ,
342
- ' -d' => $oldnode -> connstr(' regression' ),
343
- ' --create' , ' -f' => $dump_file
344
- ],
345
- ' pg_dump on source instance' );
346
-
347
- $dstnode -> command_ok(
348
- [ ' pg_restore' , ' --create' , ' -j2' , ' -d' => ' postgres' , $dump_file ],
349
- ' pg_restore to destination instance' );
350
-
351
- my $dst_dump =
352
- get_dump_for_comparison($dstnode , ' regression' , ' dest_dump' , 0);
353
-
354
- compare_files($src_dump , $dst_dump ,
355
- ' dump outputs from original and restored regression databases match' );
356
- }
357
-
358
303
# Initialize a new node for the upgrade.
359
304
my $newnode = PostgreSQL::Test::Cluster-> new(' new_node' );
360
305
361
-
362
306
# The new cluster will be initialized with different locale settings,
363
307
# but these settings will be overwritten with those of the original
364
308
# cluster.
@@ -409,10 +353,66 @@ sub get_dump_for_comparison
409
353
}
410
354
}
411
355
412
- # Stabilize stats before pg_dumpall.
356
+ # Stabilize stats before pg_dump / pg_dumpall. Doing it after initializing
357
+ # the new node gives enough time for autovacuum to update statistics on the
358
+ # old node.
413
359
$oldnode -> append_conf(' postgresql.conf' , ' autovacuum = off' );
414
360
$oldnode -> restart;
415
361
362
+ # Test that dump/restore of the regression database roundtrips cleanly. This
363
+ # doesn't work well when the nodes are different versions, so skip it in that
364
+ # case. Note that this isn't a pg_upgrade test, but it's convenient to do it
365
+ # here because we've gone to the trouble of creating the regression database.
366
+ #
367
+ # Do this while the old cluster is running before it is shut down by the
368
+ # upgrade test but after turning its autovacuum off for stable statistics.
369
+ SKIP:
370
+ {
371
+ my $dstnode = PostgreSQL::Test::Cluster-> new(' dst_node' );
372
+
373
+ skip " different Postgres versions"
374
+ if ($oldnode -> pg_version != $dstnode -> pg_version);
375
+ skip " source node not using default install"
376
+ if (defined $oldnode -> install_path);
377
+
378
+ # Setup destination database cluster with the same configuration as the
379
+ # source cluster to avoid any differences between dumps taken from both the
380
+ # clusters caused by differences in their configurations.
381
+ $dstnode -> init(%old_node_params );
382
+ # Stabilize stats for comparison.
383
+ $dstnode -> append_conf(' postgresql.conf' , ' autovacuum = off' );
384
+ $dstnode -> start;
385
+
386
+ # Use --create in dump and restore commands so that the restored
387
+ # database has the same configurable variable settings as the original
388
+ # database so that the dumps taken from both databases taken do not
389
+ # differ because of locale changes. Additionally this provides test
390
+ # coverage for --create option.
391
+ #
392
+ # Use directory format so that we can use parallel dump/restore.
393
+ my $dump_file = " $tempdir /regression.dump" ;
394
+ $oldnode -> command_ok(
395
+ [
396
+ ' pg_dump' , ' -Fd' , ' -j2' , ' --no-sync' ,
397
+ ' -d' => $oldnode -> connstr(' regression' ),
398
+ ' --create' , ' -f' => $dump_file
399
+ ],
400
+ ' pg_dump on source instance' );
401
+
402
+ $dstnode -> command_ok(
403
+ [ ' pg_restore' , ' --create' , ' -j2' , ' -d' => ' postgres' , $dump_file ],
404
+ ' pg_restore to destination instance' );
405
+
406
+ # Dump original and restored database for comparison.
407
+ my $src_dump =
408
+ get_dump_for_comparison($oldnode , ' regression' , ' src_dump' , 1);
409
+ my $dst_dump =
410
+ get_dump_for_comparison($dstnode , ' regression' , ' dest_dump' , 0);
411
+
412
+ compare_files($src_dump , $dst_dump ,
413
+ ' dump outputs from original and restored regression databases match' );
414
+ }
415
+
416
416
# Take a dump before performing the upgrade as a base comparison. Note
417
417
# that we need to use pg_dumpall from the new node here.
418
418
my @dump_command = (
0 commit comments