Revert refactoring of restore command code to shell_restore.c
authorMichael Paquier <michael@paquier.xyz>
Sun, 5 Feb 2023 23:28:42 +0000 (08:28 +0900)
committerMichael Paquier <michael@paquier.xyz>
Sun, 5 Feb 2023 23:28:42 +0000 (08:28 +0900)
commit2f6e15ac93c58c1140e4a4affe61e78f7346497a
treed2757eb6b456c8f3d882d53d711792d5ee2fdee4
parentb2d0e13a0a4c31167d01e9871f907060c80b8fae
Revert refactoring of restore command code to shell_restore.c

This reverts commits 24c35ec and 57169ad.  PreRestoreCommand() and
PostRestoreCommand() need to be put closer to the system() call calling
a restore_command, as they enable in_restore_command for the startup
process which would in turn trigger an immediate proc_exit() in the
SIGTERM handler.  Perhaps we could get rid of this behavior entirely,
but 24c35ec has made the window where the flag is enabled much larger
than it was, and any Postgres-like actions (palloc, etc.) taken by code
paths while the flag is enabled could lead to more severe issues in the
shutdown processing.

Note that curculio has showed that there are much more problems in this
area, unrelated to this change, actually, hence the issues related to
that had better be addressed first.  Keeping the code of HEAD in line
with the stable branches should make that a bit easier.

Per discussion with Andres Freund and Nathan Bossart.

Discussion: https://postgr.es/m/Y979NR3U5VnWrTwB@paquier.xyz
12 files changed:
src/backend/access/transam/Makefile
src/backend/access/transam/meson.build
src/backend/access/transam/shell_restore.c [deleted file]
src/backend/access/transam/xlog.c
src/backend/access/transam/xlogarchive.c
src/common/Makefile
src/common/archive.c [new file with mode: 0644]
src/common/meson.build
src/fe_utils/archive.c
src/include/access/xlogarchive.h
src/include/common/archive.h [new file with mode: 0644]
src/tools/msvc/Mkvcbuild.pm