On 1/21/22 22:43, Thomas Munro wrote:
> On Sat, Jan 22, 2022 at 3:55 PM Robert Haas <[email protected]> wrote:
>> On Fri, Jan 21, 2022 at 5:35 PM Andrew Dunstan <[email protected]> wrote:
>>> # See https://www.msys2.org/wiki/Porting/#filesystem-namespaces
>>> local $ENV{MSYS2_ARG_CONV_EXCL} = $source_ts_prefix;
>>> Probably in this case just setting it to 'server:' would do the trick.
>> Oh, thanks for the tip. Do you want to push a commit that does that,
>> or ... should I do it?
> Just a thought: Would it prevent the magic path translation and all
> just work if the path were already in Windows form? So, if we did
> just this change at the top:
>
> -my $tempdir = PostgreSQL::Test::Utils::tempdir;
> +my $tempdir =
> PostgreSQL::Test::Utils::perl2host(PostgreSQL::Test::Utils::tempdir);
It's not as simple as that :-( But you're on the right track. My
suggestion above doesn't work.
The rule for paths is: when you're passing a path to an external program
that's not msys aware (typically, one of our build artefacts like psql
or pg_basebackup) it needs to be a native path. But when you're passing
it to a perl function (e.g. mkdir) or to an external program that's msys
aware it needs to be a virtual path, i.e. one not mangled by perl2host.
Some recent commits to this file especially have not obeyed this rule.
Here's a patch that does it consistently for the whole file. I have
tested it on a system very like fairywren, and the test passes.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
index 95a6bd6778..7cf0480901 100644
--- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl
+++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
@@ -17,6 +17,7 @@ program_version_ok('pg_basebackup');
program_options_handling_ok('pg_basebackup');
my $tempdir = PostgreSQL::Test::Utils::tempdir;
+my $real_tempdir = PostgreSQL::Test::Utils::perl2host($tempdir);
my $node = PostgreSQL::Test::Cluster->new('main');
@@ -40,15 +41,15 @@ $node->command_fails(['pg_basebackup'],
# Sanity checks for options
$node->command_fails_like(
- [ 'pg_basebackup', '-D', "$tempdir/backup", '--compress', 'none:1' ],
+ [ 'pg_basebackup', '-D', "$real_tempdir/backup", '--compress', 'none:1' ],
qr/\Qpg_basebackup: error: cannot use compression level with method none/,
'failure if method "none" specified with compression level');
$node->command_fails_like(
- [ 'pg_basebackup', '-D', "$tempdir/backup", '--compress', 'none+' ],
+ [ 'pg_basebackup', '-D', "$real_tempdir/backup", '--compress', 'none+' ],
qr/\Qpg_basebackup: error: invalid value "none+" for option/,
'failure on incorrect separator to define compression level');
$node->command_fails_like(
- [ 'pg_basebackup', '-D', "$tempdir/backup", '--compress', 'none:' ],
+ [ 'pg_basebackup', '-D', "$real_tempdir/backup", '--compress', 'none:' ],
qr/\Qpg_basebackup: error: no compression level defined for method none/,
'failure on missing compression level value');
@@ -64,7 +65,7 @@ $node->set_replication_conf();
system_or_bail 'pg_ctl', '-D', $pgdata, 'reload';
$node->command_fails(
- [ @pg_basebackup_defs, '-D', "$tempdir/backup" ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backup" ],
'pg_basebackup fails because of WAL configuration');
ok(!-d "$tempdir/backup", 'backup directory was cleaned up');
@@ -75,7 +76,8 @@ mkdir("$tempdir/backup")
or BAIL_OUT("unable to create $tempdir/backup");
append_to_file("$tempdir/backup/dir-not-empty.txt", "Some data");
-$node->command_fails([ @pg_basebackup_defs, '-D', "$tempdir/backup", '-n' ],
+$node->command_fails([ @pg_basebackup_defs,
+ '-D', "$real_tempdir/backup", '-n' ],
'failing run with no-clean option');
ok(-d "$tempdir/backup", 'backup directory was created and left behind');
@@ -126,7 +128,8 @@ foreach my $filename (@tempRelationFiles)
}
# Run base backup.
-$node->command_ok([ @pg_basebackup_defs, '-D', "$tempdir/backup", '-X', 'none' ],
+$node->command_ok([ @pg_basebackup_defs,
+ '-D', "$real_tempdir/backup", '-X', 'none' ],
'pg_basebackup runs');
ok(-f "$tempdir/backup/PG_VERSION", 'backup was created');
ok(-f "$tempdir/backup/backup_manifest", 'backup manifest included');
@@ -187,8 +190,8 @@ rmtree("$tempdir/backup");
$node->command_ok(
[
@pg_basebackup_defs, '-D',
- "$tempdir/backup2", '--no-manifest',
- '--waldir', "$tempdir/xlog2"
+ "$real_tempdir/backup2", '--no-manifest',
+ '--waldir', "$real_tempdir/xlog2"
],
'separate xlog directory');
ok(-f "$tempdir/backup2/PG_VERSION", 'backup was created');
@@ -197,31 +200,34 @@ ok(-d "$tempdir/xlog2/", 'xlog directory was created');
rmtree("$tempdir/backup2");
rmtree("$tempdir/xlog2");
-$node->command_ok([ @pg_basebackup_defs, '-D', "$tempdir/tarbackup", '-Ft' ],
+$node->command_ok([ @pg_basebackup_defs,
+ '-D', "$real_tempdir/tarbackup", '-Ft' ],
'tar format');
ok(-f "$tempdir/tarbackup/base.tar", 'backup tar was created');
rmtree("$tempdir/tarbackup");
$node->command_fails(
- [ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-T=/foo" ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backup_foo", '-Fp', "-T=/foo" ],
'-T with empty old directory fails');
$node->command_fails(
- [ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-T/foo=" ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backup_foo", '-Fp', "-T/foo=" ],
'-T with empty new directory fails');
$node->command_fails(
[
- @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp',
+ @pg_basebackup_defs, '-D', "$real_tempdir/backup_foo", '-Fp',
"-T/foo=/bar=/baz"
],
'-T with multiple = fails');
$node->command_fails(
- [ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-Tfoo=/bar" ],
+ [ @pg_basebackup_defs,
+ '-D', "$real_tempdir/backup_foo", '-Fp', "-Tfoo=/bar" ],
'-T with old directory not absolute fails');
$node->command_fails(
- [ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-T/foo=bar" ],
+ [ @pg_basebackup_defs,
+ '-D', "$real_tempdir/backup_foo", '-Fp', "-T/foo=bar" ],
'-T with new directory not absolute fails');
$node->command_fails(
- [ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-Tfoo" ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backup_foo", '-Fp', "-Tfoo" ],
'-T with invalid format fails');
# Tar format doesn't support filenames longer than 100 bytes.
@@ -232,7 +238,7 @@ open my $file, '>', "$superlongpath"
or die "unable to create file $superlongpath";
close $file;
$node->command_fails(
- [ @pg_basebackup_defs, '-D', "$tempdir/tarbackup_l1", '-Ft' ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/tarbackup_l1", '-Ft' ],
'pg_basebackup tar with long name fails');
unlink "$pgdata/$superlongname";
@@ -266,7 +272,6 @@ dir_symlink "$tempdir", $shorter_tempdir;
mkdir "$tempdir/tblspc1";
my $realTsDir = "$real_sys_tempdir/tblspc1";
-my $real_tempdir = PostgreSQL::Test::Utils::perl2host($tempdir);
$node->safe_psql('postgres',
"CREATE TABLESPACE tblspc1 LOCATION '$realTsDir';");
$node->safe_psql('postgres',
@@ -350,13 +355,13 @@ foreach my $filename (@tempRelationFiles)
}
$node->command_fails(
- [ @pg_basebackup_defs, '-D', "$tempdir/backup1", '-Fp' ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backup1", '-Fp' ],
'plain format with tablespaces fails without tablespace mapping');
$node->command_ok(
[
@pg_basebackup_defs, '-D',
- "$tempdir/backup1", '-Fp',
+ "$real_tempdir/backup1", '-Fp',
"-T$realTsDir=$real_tempdir/tbackup/tblspc1",
],
'plain format with tablespaces succeeds with tablespace mapping');
@@ -426,7 +431,7 @@ $realTsDir =~ s/=/\\=/;
$node->command_ok(
[
@pg_basebackup_defs, '-D',
- "$tempdir/backup3", '-Fp',
+ "$real_tempdir/backup3", '-Fp',
"-T$realTsDir=$real_tempdir/tbackup/tbl\\=spc2",
],
'mapping tablespace with = sign in path');
@@ -438,12 +443,13 @@ mkdir "$tempdir/$superlongname";
$realTsDir = "$real_sys_tempdir/$superlongname";
$node->safe_psql('postgres',
"CREATE TABLESPACE tblspc3 LOCATION '$realTsDir';");
-$node->command_ok([ @pg_basebackup_defs, '-D', "$tempdir/tarbackup_l3", '-Ft' ],
+$node->command_ok([ @pg_basebackup_defs,
+ '-D', "$real_tempdir/tarbackup_l3", '-Ft' ],
'pg_basebackup tar with long symlink target');
$node->safe_psql('postgres', "DROP TABLESPACE tblspc3;");
rmtree("$tempdir/tarbackup_l3");
-$node->command_ok([ @pg_basebackup_defs, '-D', "$tempdir/backupR", '-R' ],
+$node->command_ok([ @pg_basebackup_defs, '-D', "$real_tempdir/backupR", '-R' ],
'pg_basebackup -R runs');
ok(-f "$tempdir/backupR/postgresql.auto.conf", 'postgresql.auto.conf exists');
ok(-f "$tempdir/backupR/standby.signal", 'standby.signal was created');
@@ -457,39 +463,40 @@ like(
'postgresql.auto.conf sets primary_conninfo');
$node->command_ok(
- [ @pg_basebackup_defs, '-D', "$tempdir/backupxd" ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backupxd" ],
'pg_basebackup runs in default xlog mode');
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxd/pg_wal")),
'WAL files copied');
rmtree("$tempdir/backupxd");
$node->command_ok(
- [ @pg_basebackup_defs, '-D', "$tempdir/backupxf", '-X', 'fetch' ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backupxf", '-X', 'fetch' ],
'pg_basebackup -X fetch runs');
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_wal")),
'WAL files copied');
rmtree("$tempdir/backupxf");
$node->command_ok(
- [ @pg_basebackup_defs, '-D', "$tempdir/backupxs", '-X', 'stream' ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backupxs", '-X', 'stream' ],
'pg_basebackup -X stream runs');
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxs/pg_wal")),
'WAL files copied');
rmtree("$tempdir/backupxs");
$node->command_ok(
- [ @pg_basebackup_defs, '-D', "$tempdir/backupxst", '-X', 'stream', '-Ft' ],
+ [ @pg_basebackup_defs,
+ '-D', "$real_tempdir/backupxst", '-X', 'stream', '-Ft' ],
'pg_basebackup -X stream runs in tar mode');
ok(-f "$tempdir/backupxst/pg_wal.tar", "tar file was created");
rmtree("$tempdir/backupxst");
$node->command_ok(
[
@pg_basebackup_defs, '-D',
- "$tempdir/backupnoslot", '-X',
+ "$real_tempdir/backupnoslot", '-X',
'stream', '--no-slot'
],
'pg_basebackup -X stream runs with --no-slot');
rmtree("$tempdir/backupnoslot");
$node->command_ok(
- [ @pg_basebackup_defs, '-D', "$tempdir/backupxf", '-X', 'fetch' ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backupxf", '-X', 'fetch' ],
'pg_basebackup -X fetch runs');
$node->command_fails_like(
@@ -505,7 +512,8 @@ $node->command_fails_like(
qr/unrecognized target/,
'backup target unrecognized');
$node->command_fails_like(
- [ @pg_basebackup_defs, '--target', 'blackhole', '-X', 'none', '-D', "$tempdir/blackhole" ],
+ [ @pg_basebackup_defs, '--target', 'blackhole', '-X', 'none',
+ '-D', "$real_tempdir/blackhole" ],
qr/cannot specify both output directory and backup target/,
'backup target and output directory');
$node->command_fails_like(
@@ -516,7 +524,8 @@ $node->command_ok(
[ @pg_basebackup_defs, '--target', 'blackhole', '-X', 'none' ],
'backup target blackhole');
$node->command_ok(
- [ @pg_basebackup_defs, '--target', "server:$tempdir/backuponserver", '-X', 'none' ],
+ [ @pg_basebackup_defs, '--target', "server:$real_tempdir/backuponserver",
+ '-X', 'none' ],
'backup target server');
ok(-f "$tempdir/backuponserver/base.tar", 'backup tar was created');
rmtree("$tempdir/backuponserver");
@@ -524,57 +533,59 @@ rmtree("$tempdir/backuponserver");
$node->command_fails(
[
@pg_basebackup_defs, '-D',
- "$tempdir/backupxs_sl_fail", '-X',
+ "$real_tempdir/backupxs_sl_fail", '-X',
'stream', '-S',
'slot0'
],
'pg_basebackup fails with nonexistent replication slot');
$node->command_fails(
- [ @pg_basebackup_defs, '-D', "$tempdir/backupxs_slot", '-C' ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backupxs_slot", '-C' ],
'pg_basebackup -C fails without slot name');
$node->command_fails(
[
@pg_basebackup_defs, '-D',
- "$tempdir/backupxs_slot", '-C',
+ "$real_tempdir/backupxs_slot", '-C',
'-S', 'slot0',
'--no-slot'
],
'pg_basebackup fails with -C -S --no-slot');
$node->command_fails_like(
- [ @pg_basebackup_defs, '--target', 'blackhole', '-D', "$tempdir/blackhole" ],
+ [ @pg_basebackup_defs, '--target', 'blackhole',
+ '-D', "$real_tempdir/blackhole" ],
qr/cannot specify both output directory and backup target/,
'backup target and output directory');
$node->command_ok(
- [ @pg_basebackup_defs, '-D', "$tempdir/backuptr/co", '-X', 'none' ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backuptr/co", '-X', 'none' ],
'pg_basebackup -X fetch runs');
$node->command_fails(
[
@pg_basebackup_defs, '-D',
- "$tempdir/backupxs_sl_fail", '-X',
+ "$real_tempdir/backupxs_sl_fail", '-X',
'stream', '-S',
'slot0'
],
'pg_basebackup fails with nonexistent replication slot');
$node->command_fails(
- [ @pg_basebackup_defs, '-D', "$tempdir/backupxs_slot", '-C' ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backupxs_slot", '-C' ],
'pg_basebackup -C fails without slot name');
$node->command_fails(
[
@pg_basebackup_defs, '-D',
- "$tempdir/backupxs_slot", '-C',
+ "$real_tempdir/backupxs_slot", '-C',
'-S', 'slot0',
'--no-slot'
],
'pg_basebackup fails with -C -S --no-slot');
$node->command_ok(
- [ @pg_basebackup_defs, '-D', "$tempdir/backupxs_slot", '-C', '-S', 'slot0' ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backupxs_slot",
+ '-C', '-S', 'slot0' ],
'pg_basebackup -C runs');
rmtree("$tempdir/backupxs_slot");
@@ -593,7 +604,8 @@ isnt(
'restart LSN of new slot is not null');
$node->command_fails(
- [ @pg_basebackup_defs, '-D', "$tempdir/backupxs_slot1", '-C', '-S', 'slot0' ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backupxs_slot1",
+ '-C', '-S', 'slot0' ],
'pg_basebackup fails with -C -S and a previously existing slot');
$node->safe_psql('postgres',
@@ -603,11 +615,12 @@ my $lsn = $node->safe_psql('postgres',
);
is($lsn, '', 'restart LSN of new slot is null');
$node->command_fails(
- [ @pg_basebackup_defs, '-D', "$tempdir/fail", '-S', 'slot1', '-X', 'none' ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/fail",
+ '-S', 'slot1', '-X', 'none' ],
'pg_basebackup with replication slot fails without WAL streaming');
$node->command_ok(
[
- @pg_basebackup_defs, '-D', "$tempdir/backupxs_sl", '-X',
+ @pg_basebackup_defs, '-D', "$real_tempdir/backupxs_sl", '-X',
'stream', '-S', 'slot1'
],
'pg_basebackup -X stream with replication slot runs');
@@ -619,7 +632,7 @@ rmtree("$tempdir/backupxs_sl");
$node->command_ok(
[
- @pg_basebackup_defs, '-D', "$tempdir/backupxs_sl_R", '-X',
+ @pg_basebackup_defs, '-D', "$real_tempdir/backupxs_sl_R", '-X',
'stream', '-S', 'slot1', '-R',
],
'pg_basebackup with replication slot and -R runs');
@@ -653,7 +666,7 @@ close $file;
system_or_bail 'pg_ctl', '-D', $pgdata, 'start';
$node->command_checks_all(
- [ @pg_basebackup_defs, '-D', "$tempdir/backup_corrupt" ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backup_corrupt" ],
1,
[qr{^$}],
[qr/^WARNING.*checksum verification failed/s],
@@ -673,7 +686,7 @@ close $file;
system_or_bail 'pg_ctl', '-D', $pgdata, 'start';
$node->command_checks_all(
- [ @pg_basebackup_defs, '-D', "$tempdir/backup_corrupt2" ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backup_corrupt2" ],
1,
[qr{^$}],
[qr/^WARNING.*further.*failures.*will.not.be.reported/s],
@@ -689,7 +702,7 @@ close $file;
system_or_bail 'pg_ctl', '-D', $pgdata, 'start';
$node->command_checks_all(
- [ @pg_basebackup_defs, '-D', "$tempdir/backup_corrupt3" ],
+ [ @pg_basebackup_defs, '-D', "$real_tempdir/backup_corrupt3" ],
1,
[qr{^$}],
[qr/^WARNING.*7 total checksum verification failures/s],
@@ -700,7 +713,7 @@ rmtree("$tempdir/backup_corrupt3");
$node->command_ok(
[
@pg_basebackup_defs, '-D',
- "$tempdir/backup_corrupt4", '--no-verify-checksums',
+ "$real_tempdir/backup_corrupt4", '--no-verify-checksums',
],
'pg_basebackup with -k does not report checksum mismatch');
rmtree("$tempdir/backup_corrupt4");
@@ -719,7 +732,7 @@ SKIP:
$node->command_ok(
[
@pg_basebackup_defs, '-D',
- "$tempdir/backup_gzip", '--compress',
+ "$real_tempdir/backup_gzip", '--compress',
'1', '--format',
't'
],
@@ -727,14 +740,14 @@ SKIP:
$node->command_ok(
[
@pg_basebackup_defs, '-D',
- "$tempdir/backup_gzip2", '--gzip',
+ "$real_tempdir/backup_gzip2", '--gzip',
'--format', 't'
],
'pg_basebackup with --gzip');
$node->command_ok(
[
@pg_basebackup_defs, '-D',
- "$tempdir/backup_gzip3", '--compress',
+ "$real_tempdir/backup_gzip3", '--compress',
'gzip:1', '--format',
't'
],