Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8fb13dd

Browse files
Move extra code out of the Pre/PostRestoreCommand() section.
If SIGTERM is received within this section, the startup processwill immediately proc_exit() in the signal handler, so it isinadvisable to include any more code than is required there (assuch code is unlikely to be compatible with doing proc_exit() in asignal handler). This commit moves the code recently added to thissection (see1b06d7b and7fed801) to outside of the section.This ensures that the startup process only calls proc_exit() in itsSIGTERM handler for the duration of the system() call, which is howthis code worked from v8.4 to v14.Reported-by: Michael Paquier, Thomas MunroAnalyzed-by: Andres FreundSuggested-by: Tom LaneReviewed-by: Michael Paquier, Robert Haas, Thomas Munro, Andres FreundDiscussion:https://postgr.es/m/Y9nGDSgIm83FHcad%40paquier.xyzDiscussion:https://postgr.es/m/20230223231503.GA743455%40nathanxps13Backpatch-through: 15
1 parenta70bce4 commit8fb13dd

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

‎src/backend/access/transam/xlogarchive.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,27 @@ RestoreArchivedFile(char *path, const char *xlogfname,
159159
(errmsg_internal("executing restore command \"%s\"",
160160
xlogRestoreCmd)));
161161

162+
fflush(NULL);
163+
pgstat_report_wait_start(WAIT_EVENT_RESTORE_COMMAND);
164+
162165
/*
163-
* Check signals before restore command and reset afterwards.
166+
* PreRestoreCommand() informs the SIGTERM handler for the startup process
167+
* that it should proc_exit() right away. This is done for the duration
168+
* of the system() call because there isn't a good way to break out while
169+
* it is executing. Since we might call proc_exit() in a signal handler,
170+
* it is best to put any additional logic before or after the
171+
* PreRestoreCommand()/PostRestoreCommand() section.
164172
*/
165173
PreRestoreCommand();
166174

167175
/*
168176
* Copy xlog from archival storage to XLOGDIR
169177
*/
170-
fflush(NULL);
171-
pgstat_report_wait_start(WAIT_EVENT_RESTORE_COMMAND);
172178
rc=system(xlogRestoreCmd);
173-
pgstat_report_wait_end();
174179

175180
PostRestoreCommand();
181+
182+
pgstat_report_wait_end();
176183
pfree(xlogRestoreCmd);
177184

178185
if (rc==0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp