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

Commitad8b674

Browse files
committed
Shut down transaction tracking at startup process exit.
Maxim Orlov reported that the shutdown of standby server could result inthe following assertion failure. The cause of this issue was that,when the shutdown caused the startup process to exit, recovery-timetransaction tracking was not shut down even if it's already initialized,and some locks the tracked transactions were holding could not be released.At this situation, if other process was invoked and the PGPROC entry thatthe startup process used was assigned to it, it found such unreleased locksand caused the assertion failure, during the initialization of it. TRAP: FailedAssertion("SHMQueueEmpty(&(MyProc->myProcLocks[i]))"This commit fixes this issue by making the startup process shut downtransaction tracking and release all locks, at the exit of it.Back-patch to all supported branches.Reported-by: Maxim OrlovAuthor: Fujii MasaoReviewed-by: Maxim OrlovDiscussion:https://postgr.es/m/ad4ce692cc1d89a093b471ab1d969b0b@postgrespro.ru
1 parent6734e80 commitad8b674

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

‎src/backend/postmaster/startup.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ static volatile sig_atomic_t in_restore_command = false;
6262
staticvoidStartupProcTriggerHandler(SIGNAL_ARGS);
6363
staticvoidStartupProcSigHupHandler(SIGNAL_ARGS);
6464

65+
/* Callbacks */
66+
staticvoidStartupProcExit(intcode,Datumarg);
67+
6568

6669
/* --------------------------------
6770
*signal handler routines
@@ -183,13 +186,29 @@ HandleStartupProcInterrupts(void)
183186
}
184187

185188

189+
/* --------------------------------
190+
*signal handler routines
191+
* --------------------------------
192+
*/
193+
staticvoid
194+
StartupProcExit(intcode,Datumarg)
195+
{
196+
/* Shutdown the recovery environment */
197+
if (standbyState!=STANDBY_DISABLED)
198+
ShutdownRecoveryTransactionEnvironment();
199+
}
200+
201+
186202
/* ----------------------------------
187203
*Startup Process main entry point
188204
* ----------------------------------
189205
*/
190206
void
191207
StartupProcessMain(void)
192208
{
209+
/* Arrange to clean up at startup process exit */
210+
on_shmem_exit(StartupProcExit,0);
211+
193212
/*
194213
* Properly accept or ignore signals the postmaster might send us.
195214
*/

‎src/backend/storage/ipc/standby.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,25 @@ InitRecoveryTransactionEnvironment(void)
127127
*
128128
* Prepare to switch from hot standby mode to normal operation. Shut down
129129
* recovery-time transaction tracking.
130+
*
131+
* This must be called even in shutdown of startup process if transaction
132+
* tracking has been initialized. Otherwise some locks the tracked
133+
* transactions were holding will not be released and and may interfere with
134+
* the processes still running (but will exit soon later) at the exit of
135+
* startup process.
130136
*/
131137
void
132138
ShutdownRecoveryTransactionEnvironment(void)
133139
{
140+
/*
141+
* Do nothing if RecoveryLockLists is NULL because which means that
142+
* transaction tracking has not been yet initialized or has been already
143+
* shutdowned. This prevents transaction tracking from being shutdowned
144+
* unexpectedly more than once.
145+
*/
146+
if (RecoveryLockLists==NULL)
147+
return;
148+
134149
/* Mark all tracked in-progress transactions as finished. */
135150
ExpireAllKnownAssignedTransactionIds();
136151

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp