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

Commit80259d4

Browse files
committed
While waiting for a condition variable, detect postmaster death.
The general assumption for postmaster child processes is that theyshould just exit(1), reasonably promptly, if the postmaster disappears.condition_variable.c neglected this consideration and could be leftwaiting forever, if the counterpart process it is waiting for hasdone the right thing and exited.We had some discussion of adjusting the WaitEventSet API to make itharder to make this type of mistake in future; but for the moment,and for v10, let's make this narrow fix.Discussion:https://postgr.es/m/20412.1515456143@sss.pgh.pa.us
1 parentc3d41cc commit80259d4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

‎src/backend/storage/lmgr/condition_variable.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ ConditionVariablePrepareToSleep(ConditionVariable *cv)
6969
{
7070
WaitEventSet*new_event_set;
7171

72-
new_event_set=CreateWaitEventSet(TopMemoryContext,1);
72+
new_event_set=CreateWaitEventSet(TopMemoryContext,2);
7373
AddWaitEventToSet(new_event_set,WL_LATCH_SET,PGINVALID_SOCKET,
7474
MyLatch,NULL);
75+
AddWaitEventToSet(new_event_set,WL_POSTMASTER_DEATH,PGINVALID_SOCKET,
76+
NULL,NULL);
7577
/* Don't set cv_wait_event_set until we have a correct WES. */
7678
cv_wait_event_set=new_event_set;
7779
}
@@ -149,11 +151,20 @@ ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
149151
CHECK_FOR_INTERRUPTS();
150152

151153
/*
152-
* Wait for latch to be set.We don't care about the result because
153-
*our contract permits spurious returns.
154+
* Wait for latch to be set.(If we're awakened for some other
155+
*reason, the code below will cope anyway.)
154156
*/
155157
WaitEventSetWait(cv_wait_event_set,-1,&event,1,wait_event_info);
156158

159+
if (event.events&WL_POSTMASTER_DEATH)
160+
{
161+
/*
162+
* Emergency bailout if postmaster has died. This is to avoid the
163+
* necessity for manual cleanup of all postmaster children.
164+
*/
165+
exit(1);
166+
}
167+
157168
/* Reset latch before examining the state of the wait list. */
158169
ResetLatch(MyLatch);
159170

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp