Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 82023d4

Browse files
committed
Revert recent ill-advised test case changes.
Commit 6bf5c42 cannot work on Windows, because it lacks symlink support. While the bug fix in commit cd64dc4 is correct as far as I know, the test case changes depend on the previous commit, so this will have to live without test coverage until we can come up with a better solution. Commit fa7036d was a test case bug fix on top of those two, to prevent failures on Linux, so that has to come out as well. Per the buildfarm, CI, and Thomas Munro.
1 parent fa7036d commit 82023d4

File tree

3 files changed

+28
-118
lines changed

3 files changed

+28
-118
lines changed

src/bin/pg_basebackup/t/010_pg_basebackup.pl

+17-4
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,25 @@
407407

408408
my $node2 = PostgreSQL::Test::Cluster->new('replica');
409409

410-
# Recover the backup
410+
# Recover main data directory
411+
$node2->init_from_backup($node, 'tarbackup2', tar_program => $tar);
412+
413+
# Recover tablespace into a new directory (not where it was!)
414+
my $repTsDir = "$tempdir/tblspc1replica";
415+
my $realRepTsDir = "$real_sys_tempdir/tblspc1replica";
416+
mkdir $repTsDir;
417+
PostgreSQL::Test::Utils::system_or_bail($tar, 'xf', $tblspc_tars[0],
418+
'-C', $repTsDir);
419+
420+
# Update tablespace map to point to new directory.
421+
# XXX Ideally pg_basebackup would handle this.
411422
$tblspc_tars[0] =~ m|/([0-9]*)\.tar$|;
412423
my $tblspcoid = $1;
413-
my $realRepTsDir = "$real_sys_tempdir/tblspc1replica";
414-
$node2->init_from_backup($node, 'tarbackup2', tar_program => $tar,
415-
'tablespace_map' => { $tblspcoid => $realRepTsDir });
424+
my $escapedRepTsDir = $realRepTsDir;
425+
$escapedRepTsDir =~ s/\\/\\\\/g;
426+
open my $mapfile, '>', $node2->data_dir . '/tablespace_map' or die $!;
427+
print $mapfile "$tblspcoid $escapedRepTsDir\n";
428+
close $mapfile;
416429

417430
$node2->start;
418431
my $result = $node2->safe_psql('postgres', 'SELECT * FROM test1');

src/bin/pg_combinebackup/t/002_compare_backups.pl

+4-28
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@
77
use PostgreSQL::Test::Utils;
88
use Test::More;
99

10-
my $tempdir = PostgreSQL::Test::Utils::tempdir_short();
11-
1210
# Set up a new database instance.
1311
my $primary = PostgreSQL::Test::Cluster->new('primary');
1412
$primary->init(has_archiving => 1, allows_streaming => 1);
1513
$primary->append_conf('postgresql.conf', 'summarize_wal = on');
1614
$primary->start;
17-
my $tsprimary = $tempdir . '/ts';
18-
mkdir($tsprimary) || die "mkdir $tsprimary: $!";
1915

2016
# Create some test tables, each containing one row of data, plus a whole
2117
# extra database.
@@ -33,49 +29,33 @@
3329
CREATE TABLE will_get_rewritten (a int, b text);
3430
INSERT INTO will_get_rewritten VALUES (1, 'initial test row');
3531
CREATE DATABASE db_will_get_dropped;
36-
CREATE TABLESPACE ts1 LOCATION '$tsprimary';
37-
CREATE TABLE will_not_change_in_ts (a int, b text) TABLESPACE ts1;
38-
INSERT INTO will_not_change_in_ts VALUES (1, 'initial test row');
39-
CREATE TABLE will_change_in_ts (a int, b text) TABLESPACE ts1;
40-
INSERT INTO will_change_in_ts VALUES (1, 'initial test row');
41-
CREATE TABLE will_get_dropped_in_ts (a int, b text);
42-
INSERT INTO will_get_dropped_in_ts VALUES (1, 'initial test row');
4332
EOM
4433

4534
# Take a full backup.
4635
my $backup1path = $primary->backup_dir . '/backup1';
47-
my $tsbackup1path = $tempdir . '/ts1backup';
48-
mkdir($tsbackup1path) || die "mkdir $tsbackup1path: $!";
4936
$primary->command_ok(
50-
[ 'pg_basebackup', '-D', $backup1path, '--no-sync', '-cfast',
51-
"-T${tsprimary}=${tsbackup1path}" ], "full backup");
37+
[ 'pg_basebackup', '-D', $backup1path, '--no-sync', '-cfast' ],
38+
"full backup");
5239

5340
# Now make some database changes.
5441
$primary->safe_psql('postgres', <<EOM);
5542
UPDATE will_change SET b = 'modified value' WHERE a = 1;
56-
UPDATE will_change_in_ts SET b = 'modified value' WHERE a = 1;
5743
INSERT INTO will_grow
5844
SELECT g, 'additional row' FROM generate_series(2, 5000) g;
5945
TRUNCATE will_shrink;
6046
VACUUM will_get_vacuumed;
6147
DROP TABLE will_get_dropped;
62-
DROP TABLE will_get_dropped_in_ts;
6348
CREATE TABLE newly_created (a int, b text);
6449
INSERT INTO newly_created VALUES (1, 'row for new table');
65-
CREATE TABLE newly_created_in_ts (a int, b text) TABLESPACE ts1;
66-
INSERT INTO newly_created_in_ts VALUES (1, 'row for new table');
6750
VACUUM FULL will_get_rewritten;
6851
DROP DATABASE db_will_get_dropped;
6952
CREATE DATABASE db_newly_created;
7053
EOM
7154

7255
# Take an incremental backup.
7356
my $backup2path = $primary->backup_dir . '/backup2';
74-
my $tsbackup2path = $tempdir . '/tsbackup2';
75-
mkdir($tsbackup2path) || die "mkdir $tsbackup2path: $!";
7657
$primary->command_ok(
7758
[ 'pg_basebackup', '-D', $backup2path, '--no-sync', '-cfast',
78-
"-T${tsprimary}=${tsbackup2path}",
7959
'--incremental', $backup1path . '/backup_manifest' ],
8060
"incremental backup");
8161

@@ -98,11 +78,9 @@
9878
# Perform PITR from the full backup. Disable archive_mode so that the archive
9979
# doesn't find out about the new timeline; that way, the later PITR below will
10080
# choose the same timeline.
101-
my $tspitr1path = $tempdir . '/tspitr1';
10281
my $pitr1 = PostgreSQL::Test::Cluster->new('pitr1');
10382
$pitr1->init_from_backup($primary, 'backup1',
104-
standby => 1, has_restoring => 1,
105-
tablespace_map => { $tsbackup1path => $tspitr1path });
83+
standby => 1, has_restoring => 1);
10684
$pitr1->append_conf('postgresql.conf', qq{
10785
recovery_target_lsn = '$lsn'
10886
recovery_target_action = 'promote'
@@ -112,12 +90,10 @@
11290

11391
# Perform PITR to the same LSN from the incremental backup. Use the same
11492
# basic configuration as before.
115-
my $tspitr2path = $tempdir . '/tspitr2';
11693
my $pitr2 = PostgreSQL::Test::Cluster->new('pitr2');
11794
$pitr2->init_from_backup($primary, 'backup2',
11895
standby => 1, has_restoring => 1,
119-
combine_with_prior => [ 'backup1' ],
120-
tablespace_map => { $tsbackup2path => $tspitr2path });
96+
combine_with_prior => [ 'backup1' ]);
12197
$pitr2->append_conf('postgresql.conf', qq{
12298
recovery_target_lsn = '$lsn'
12399
recovery_target_action = 'promote'

src/test/perl/PostgreSQL/Test/Cluster.pm

+7-86
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ sub backup_fs_cold
777777

778778
=pod
779779
780-
=item $node->init_from_backup(root_node, backup_name, %params)
780+
=item $node->init_from_backup(root_node, backup_name)
781781
782782
Initialize a node from a backup, which may come from this node or a different
783783
node. root_node must be a PostgreSQL::Test::Cluster reference, backup_name the string name
@@ -787,13 +787,8 @@ Does not start the node after initializing it.
787787
788788
By default, the backup is assumed to be plain format. To restore from
789789
a tar-format backup, pass the name of the tar program to use in the
790-
keyword parameter tar_program.
791-
792-
If there are tablespace present in the backup, include tablespace_map as
793-
a keyword parameter whose values is a hash. When tar_program is used, the
794-
hash keys are tablespace OIDs; otherwise, they are the tablespace pathnames
795-
used in the backup. In either case, the values are the tablespace pathnames
796-
that should be used for the target cluster.
790+
keyword parameter tar_program. Note that tablespace tar files aren't
791+
handled here.
797792
798793
To restore from an incremental backup, pass the parameter combine_with_prior
799794
as a reference to an array of prior backup names with which this backup
@@ -848,98 +843,24 @@ sub init_from_backup
848843
}
849844

850845
local %ENV = $self->_get_env();
851-
my @combineargs = ('pg_combinebackup', '-d');
852-
if (exists $params{tablespace_map})
853-
{
854-
while (my ($olddir, $newdir) = each %{$params{tablespace_map}})
855-
{
856-
push @combineargs, "-T$olddir=$newdir";
857-
}
858-
}
859-
push @combineargs, @prior_backup_path, $backup_path, '-o', $data_path;
860-
PostgreSQL::Test::Utils::system_or_bail(@combineargs);
846+
PostgreSQL::Test::Utils::system_or_bail('pg_combinebackup', '-d',
847+
@prior_backup_path, $backup_path, '-o', $data_path);
861848
}
862849
elsif (defined $params{tar_program})
863850
{
864-
mkdir($data_path) || die "mkdir $data_path: $!";
851+
mkdir($data_path);
865852
PostgreSQL::Test::Utils::system_or_bail($params{tar_program}, 'xf',
866853
$backup_path . '/base.tar',
867854
'-C', $data_path);
868855
PostgreSQL::Test::Utils::system_or_bail(
869856
$params{tar_program}, 'xf',
870857
$backup_path . '/pg_wal.tar', '-C',
871858
$data_path . '/pg_wal');
872-
873-
# We need to generate a tablespace_map file.
874-
open(my $tsmap, ">", "$data_path/tablespace_map")
875-
|| die "$data_path/tablespace_map: $!";
876-
877-
# Extract tarfiles and add tablespace_map entries
878-
my @tstars = grep { /^\d+.tar/ }
879-
PostgreSQL::Test::Utils::slurp_dir($backup_path);
880-
for my $tstar (@tstars)
881-
{
882-
my $tsoid = $tstar;
883-
$tsoid =~ s/\.tar$//;
884-
885-
die "no tablespace mapping for $tstar"
886-
if !exists $params{tablespace_map} ||
887-
!exists $params{tablespace_map}{$tsoid};
888-
my $newdir = $params{tablespace_map}{$tsoid};
889-
890-
mkdir($newdir) || die "mkdir $newdir: $!";
891-
PostgreSQL::Test::Utils::system_or_bail($params{tar_program}, 'xf',
892-
$backup_path . '/' . $tstar, '-C', $newdir);
893-
894-
my $escaped_newdir = $newdir;
895-
$escaped_newdir =~ s/\\/\\\\/g;
896-
print $tsmap "$tsoid $escaped_newdir\n";
897-
}
898-
899-
# Close tablespace_map.
900-
close($tsmap);
901859
}
902860
else
903861
{
904-
my @tsoids;
905862
rmdir($data_path);
906-
907-
# Copy the main backup. Exclude tablespace links, but remember them.
908-
PostgreSQL::Test::RecursiveCopy::copypath($backup_path, $data_path,
909-
'filterfn' => sub {
910-
my ($path) = @_;
911-
if ($path =~ /^pg_tblspc\/(\d+)$/ && -l "$backup_path/$path")
912-
{
913-
push @tsoids, $1;
914-
return 0;
915-
}
916-
return 1;
917-
});
918-
919-
# We need to generate a tablespace_map file.
920-
open(my $tsmap, ">", "$data_path/tablespace_map")
921-
|| die "$data_path/tablespace_map: $!";
922-
923-
# Now use the list of tablespace links to copy each tablespace.
924-
for my $tsoid (@tsoids)
925-
{
926-
my $olddir = readlink("$backup_path/pg_tblspc/$tsoid")
927-
|| die "readlink $backup_path/pg_tblspc/$tsoid: $!";
928-
929-
die "no tablespace mapping for $olddir"
930-
if !exists $params{tablespace_map} ||
931-
!exists $params{tablespace_map}{$olddir};
932-
933-
my $newdir = $params{tablespace_map}{$olddir};
934-
PostgreSQL::Test::RecursiveCopy::copypath($olddir, $newdir);
935-
936-
my $escaped_newdir = $newdir;
937-
$escaped_newdir =~ s/\\/\\\\/g;
938-
print $tsmap "$tsoid $escaped_newdir\n";
939-
}
940-
941-
# Close tablespace_map.
942-
close($tsmap);
863+
PostgreSQL::Test::RecursiveCopy::copypath($backup_path, $data_path);
943864
}
944865
chmod(0700, $data_path) or die $!;
945866

0 commit comments

Comments
 (0)