BUG #18971: Server passes an invalid (indirect) path in PGDATA to the external program - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #18971: Server passes an invalid (indirect) path in PGDATA to the external program
Date
Msg-id 18971-53687392b125e4bf@postgresql.org
Whole thread Raw
Responses Re: BUG #18971: Server passes an invalid (indirect) path in PGDATA to the external program
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18971
Logged by:          Dmitry Kovalenko
Email address:      d.kovalenko@postgrespro.ru
PostgreSQL version: 18beta1
Operating system:   Ubuntu 2024.04
Description:

Hello,
PG version is 18beta1 (bbccf7ec)
OS is Ubunty 24.04
---------- SHORT DESCRIPTION
Server passes an invalid (indirect) path in PGDATA to the external program.
Server must provide to the external programs a right, absolute path in
PGDATA.
---------- FULL DESCRIPTION / STEPS
1) Our SPECIAL test starts PG with an indirect path to the database cluster
files:
CWD is:
"/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01"
COMMAND is:
pg_ctl start -D

"../../../../../../../../../../../..//home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/tests/tmp_dirs/ArchiveTest/test_archive_get_relative_path/restored/data"
-l

"../../../../../../../../../../../..//home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/tests/tmp_dirs/ArchiveTest/test_archive_get_relative_path/restored/logs/postgres.log"
postgresql.auto.conf of this cluster has the following lines:
------ [begin of postgresql.auto.conf]
archive_mode =  'on'
archive_command =  'exec

"/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/builddir/src/pg_probackup3"
archive-push -B

/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/tests/tmp_dirs/ArchiveTest/test_archive_get_relative_path/backup
--instance=node --compress-algorithm=zlib --log-level-console=trace
--no-sync --wal-file-path=%p --wal-file-name=%f'
recovery_target_timeline =  'current'
recovery_target_action =  'pause'
restore_command =

'"/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/builddir/src/pg_probackup3"
archive-get -B

"/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/tests/tmp_dirs/ArchiveTest/test_archive_get_relative_path/backup"
--instance "node" --wal-file-path=%p --wal-file-name=%f'
------ [/end of postgresql.auto.conf]
2) pc_ctl starts the postmaster with this PWD:
"/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01"
So, the path to the cluster files in "-D" is valid and is:

"/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/tests/tmp_dirs/ArchiveTest/test_archive_get_relative_path/restored/data"
3) During start Postgres runs the external program pg_probackup3 with the
following commandline (I got it with "ps -eo args | grep probackup"):
sh -c --

"/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/builddir/src/pg_probackup3"
archive-get -B

"/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/tests/tmp_dirs/ArchiveTest/test_archive_get_relative_path/backup"
--instance "node" --wal-file-path=pg_wal/RECOVERYXLOG
--wal-file-name=000000010000000000000002
This command runs the next process:

/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/builddir/src/pg_probackup3
archive-get -B

/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/tests/tmp_dirs/ArchiveTest/test_archive_get_relative_path/backup
--instance node --wal-file-path=pg_wal/RECOVERYXLOG
--wal-file-name=000000010000000000000002
4) pg_probackup3 process has the following environment variables:

PWD="/home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/tests/tmp_dirs/ArchiveTest/test_archive_get_relative_path/restored/data"

PGDATA="../../../../../../../../../../../../home/dima/MY/Work/CurrentTasks/2025/PBCKP-2289/_Iter003/001--Vanilla-master/Probackup3/work01/tests/tmp_dirs/ArchiveTest/test_archive_get_relative_path/restored/data"
---------- PROBLEM
PGDATA (4) is invalid for pg_probackup3. Because PWD of probackup (4) != PWD
of server (2).
When probackup is trying to use this PGDATA, it fails.
Server must provide to the external programs a right, absolute path in
PGDATA.
Thanks&Regards,
Dmitry Kovalenko,
Postgres Professional, Russia


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18970: Atempt to alter type of table column used in row type with check leads to assertion failure
Next
From: Tom Lane
Date:
Subject: Re: BUG #18971: Server passes an invalid (indirect) path in PGDATA to the external program