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

Commite7bcfd7

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 parentfd91fed commite7bcfd7

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
@@ -51,6 +51,9 @@ static volatile sig_atomic_t in_restore_command = false;
5151
staticvoidStartupProcTriggerHandler(SIGNAL_ARGS);
5252
staticvoidStartupProcSigHupHandler(SIGNAL_ARGS);
5353

54+
/* Callbacks */
55+
staticvoidStartupProcExit(intcode,Datumarg);
56+
5457

5558
/* --------------------------------
5659
*signal handler routines
@@ -162,13 +165,29 @@ HandleStartupProcInterrupts(void)
162165
}
163166

164167

168+
/* --------------------------------
169+
*signal handler routines
170+
* --------------------------------
171+
*/
172+
staticvoid
173+
StartupProcExit(intcode,Datumarg)
174+
{
175+
/* Shutdown the recovery environment */
176+
if (standbyState!=STANDBY_DISABLED)
177+
ShutdownRecoveryTransactionEnvironment();
178+
}
179+
180+
165181
/* ----------------------------------
166182
*Startup Process main entry point
167183
* ----------------------------------
168184
*/
169185
void
170186
StartupProcessMain(void)
171187
{
188+
/* Arrange to clean up at startup process exit */
189+
on_shmem_exit(StartupProcExit,0);
190+
172191
/*
173192
* Properly accept or ignore signals the postmaster might send us.
174193
*/

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

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp