diff options
author | Michael Paquier <michael@paquier.xyz> | 2023-02-06 08:28:42 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2023-02-06 08:28:42 +0900 |
commit | 2f6e15ac93c58c1140e4a4affe61e78f7346497a (patch) | |
tree | d2757eb6b456c8f3d882d53d711792d5ee2fdee4 /src/backend/access/transam/xlog.c | |
parent | b2d0e13a0a4c31167d01e9871f907060c80b8fae (diff) | |
download | postgresql-2f6e15ac93c58c1140e4a4affe61e78f7346497a.tar.gz postgresql-2f6e15ac93c58c1140e4a4affe61e78f7346497a.zip |
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
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r-- | src/backend/access/transam/xlog.c | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index fb4c860bdea..f9f0f6db8d1 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -692,7 +692,6 @@ static char *GetXLogBuffer(XLogRecPtr ptr, TimeLineID tli); static XLogRecPtr XLogBytePosToRecPtr(uint64 bytepos); static XLogRecPtr XLogBytePosToEndRecPtr(uint64 bytepos); static uint64 XLogRecPtrToBytePos(XLogRecPtr ptr); -static void GetOldestRestartPointFileName(char *fname); static void WALInsertLockAcquire(void); static void WALInsertLockAcquireExclusive(void); @@ -4890,12 +4889,10 @@ CleanupAfterArchiveRecovery(TimeLineID EndOfLogTLI, XLogRecPtr EndOfLog, * Execute the recovery_end_command, if any. */ if (recoveryEndCommand && strcmp(recoveryEndCommand, "") != 0) - { - char lastRestartPointFname[MAXFNAMELEN]; - - GetOldestRestartPointFileName(lastRestartPointFname); - shell_recovery_end(lastRestartPointFname); - } + ExecuteRecoveryCommand(recoveryEndCommand, + "recovery_end_command", + true, + WAIT_EVENT_RECOVERY_END_COMMAND); /* * We switched to a new timeline. Clean up segments on the old timeline. @@ -7312,12 +7309,10 @@ CreateRestartPoint(int flags) * Finally, execute archive_cleanup_command, if any. */ if (archiveCleanupCommand && strcmp(archiveCleanupCommand, "") != 0) - { - char lastRestartPointFname[MAXFNAMELEN]; - - GetOldestRestartPointFileName(lastRestartPointFname); - shell_archive_cleanup(lastRestartPointFname); - } + ExecuteRecoveryCommand(archiveCleanupCommand, + "archive_cleanup_command", + false, + WAIT_EVENT_ARCHIVE_CLEANUP_COMMAND); return true; } @@ -8894,22 +8889,6 @@ GetOldestRestartPoint(XLogRecPtr *oldrecptr, TimeLineID *oldtli) LWLockRelease(ControlFileLock); } -/* - * Returns the WAL file name for the last checkpoint or restartpoint. This is - * the oldest WAL file that we still need if we have to restart recovery. - */ -static void -GetOldestRestartPointFileName(char *fname) -{ - XLogRecPtr restartRedoPtr; - TimeLineID restartTli; - XLogSegNo restartSegNo; - - GetOldestRestartPoint(&restartRedoPtr, &restartTli); - XLByteToSeg(restartRedoPtr, restartSegNo, wal_segment_size); - XLogFileName(fname, restartTli, restartSegNo, wal_segment_size); -} - /* Thin wrapper around ShutdownWalRcv(). */ void XLogShutdownWalRcv(void) |