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

Commit7aa815a

Browse files
committed
Make pg_promote() detect postmaster death while waiting for promotion to end.
Previously even if postmaster died and WaitLatch() woke up with that eventwhile pg_promote() was waiting for the standby promotion to finish,pg_promote() did nothing special and kept waiting until timeout occurred.This could cause a busy loop.This patch make pg_promote() return false immediately when postmasterdies, to avoid such a busy loop.Back-patch to v12 where pg_promote() was added.Author: Fujii MasaoReviewed-by: Michael PaquierDiscussion:https://postgr.es/m/CAHGQGwEs9ROgSp+QF+YdDU+xP8W=CY1k-_Ov-d_Z3JY+to3eXA@mail.gmail.com
1 parent4c3e750 commit7aa815a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,17 +759,26 @@ pg_promote(PG_FUNCTION_ARGS)
759759
#defineWAITS_PER_SECOND 10
760760
for (i=0;i<WAITS_PER_SECOND*wait_seconds;i++)
761761
{
762+
intrc;
763+
762764
ResetLatch(MyLatch);
763765

764766
if (!RecoveryInProgress())
765767
PG_RETURN_BOOL(true);
766768

767769
CHECK_FOR_INTERRUPTS();
768770

769-
(void)WaitLatch(MyLatch,
770-
WL_LATCH_SET |WL_TIMEOUT |WL_POSTMASTER_DEATH,
771-
1000L /WAITS_PER_SECOND,
772-
WAIT_EVENT_PROMOTE);
771+
rc=WaitLatch(MyLatch,
772+
WL_LATCH_SET |WL_TIMEOUT |WL_POSTMASTER_DEATH,
773+
1000L /WAITS_PER_SECOND,
774+
WAIT_EVENT_PROMOTE);
775+
776+
/*
777+
* Emergency bailout if postmaster has died. This is to avoid the
778+
* necessity for manual cleanup of all postmaster children.
779+
*/
780+
if (rc&WL_POSTMASTER_DEATH)
781+
PG_RETURN_BOOL(false);
773782
}
774783

775784
ereport(WARNING,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp