Skip to content

Commit 4b719e1

Browse files
committed
Symlink pg_replslot robustly on Windows in pg_basebackup test
This reverts commit e9f15bc. Instead of a hacky solution that didn't work on Windows, we avoid trying to move the directory possibly across drives, and instead remove it and recreate it in the new location. Discussion: https://postgr.es/m/20240707070243.sb77kp4ubowauctz@awork3.anarazel.de Backpatch to release 14 like the previous patch.
1 parent b7d3be6 commit 4b719e1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,13 @@
234234
# Create a temporary directory in the system location.
235235
my $sys_tempdir = TestLib::tempdir_short;
236236

237-
# On Windows use the short location to avoid path length issues.
238-
# Elsewhere use $tempdir to avoid file system boundary issues with moving.
239-
my $tmploc = $windows_os ? $sys_tempdir : $tempdir;
240-
241-
rename("$pgdata/pg_replslot", "$tmploc/pg_replslot")
242-
or BAIL_OUT "could not move $pgdata/pg_replslot";
243-
dir_symlink("$tmploc/pg_replslot", "$pgdata/pg_replslot")
237+
# pg_replslot should be empty. We remove it and recreate it in $sys_tempdir
238+
# before symlinking, in order to avoid possibly trying to move things across
239+
# drives.
240+
rmdir("$pgdata/pg_replslot")
241+
or BAIL_OUT "could not remove $pgdata/pg_replslot";
242+
mkdir("$sys_tempdir/pg_replslot"); # if this fails the symlink will fail
243+
dir_symlink("$sys_tempdir/pg_replslot", "$pgdata/pg_replslot")
244244
or BAIL_OUT "could not symlink to $pgdata/pg_replslot";
245245

246246
$node->start;

0 commit comments

Comments
 (0)