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

Commitdd5b7e4

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 parent48b319e commitdd5b7e4

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
@@ -54,6 +54,9 @@ static void StartupProcSigUsr1Handler(SIGNAL_ARGS);
5454
staticvoidStartupProcTriggerHandler(SIGNAL_ARGS);
5555
staticvoidStartupProcSigHupHandler(SIGNAL_ARGS);
5656

57+
/* Callbacks */
58+
staticvoidStartupProcExit(intcode,Datumarg);
59+
5760

5861
/* --------------------------------
5962
*signal handler routines
@@ -165,13 +168,29 @@ HandleStartupProcInterrupts(void)
165168
}
166169

167170

171+
/* --------------------------------
172+
*signal handler routines
173+
* --------------------------------
174+
*/
175+
staticvoid
176+
StartupProcExit(intcode,Datumarg)
177+
{
178+
/* Shutdown the recovery environment */
179+
if (standbyState!=STANDBY_DISABLED)
180+
ShutdownRecoveryTransactionEnvironment();
181+
}
182+
183+
168184
/* ----------------------------------
169185
*Startup Process main entry point
170186
* ----------------------------------
171187
*/
172188
void
173189
StartupProcessMain(void)
174190
{
191+
/* Arrange to clean up at startup process exit */
192+
on_shmem_exit(StartupProcExit,0);
193+
175194
/*
176195
* Properly accept or ignore signals the postmaster might send us.
177196
*/

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,25 @@ InitRecoveryTransactionEnvironment(void)
124124
*
125125
* Prepare to switch from hot standby mode to normal operation. Shut down
126126
* recovery-time transaction tracking.
127+
*
128+
* This must be called even in shutdown of startup process if transaction
129+
* tracking has been initialized. Otherwise some locks the tracked
130+
* transactions were holding will not be released and and may interfere with
131+
* the processes still running (but will exit soon later) at the exit of
132+
* startup process.
127133
*/
128134
void
129135
ShutdownRecoveryTransactionEnvironment(void)
130136
{
137+
/*
138+
* Do nothing if RecoveryLockLists is NULL because which means that
139+
* transaction tracking has not been yet initialized or has been already
140+
* shutdowned. This prevents transaction tracking from being shutdowned
141+
* unexpectedly more than once.
142+
*/
143+
if (RecoveryLockLists==NULL)
144+
return;
145+
131146
/* Mark all tracked in-progress transactions as finished. */
132147
ExpireAllKnownAssignedTransactionIds();
133148

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp