public inbox for [email protected]
help / color / mirror / Atom feedFrom: Andres Freund <[email protected]>
Subject: [PATCH vREL_10_STABLE 1/2] Fix possibility of self-deadlock in ResolveRecoveryConflictWithBufferPin().
Date: Fri, 29 Apr 2022 12:50:10 -0700
Author:
Reviewed-By:
Discussion: https://postgr.es/m/[email protected]
Backpatch:
---
src/backend/storage/ipc/standby.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 863cb641007..47cdaead9e6 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -44,6 +44,7 @@ static HTAB *RecoveryLockLists;
/* Flags set by timeout handlers */
static volatile sig_atomic_t got_standby_deadlock_timeout = false;
+static volatile sig_atomic_t got_standby_delay_timeout = false;
static volatile sig_atomic_t got_standby_lock_timeout = false;
static void ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
@@ -593,10 +594,15 @@ ResolveRecoveryConflictWithBufferPin(void)
enable_timeouts(timeouts, cnt);
}
- /* Wait to be signaled by UnpinBuffer() */
+ /*
+ * Wait to be signaled by UnpinBuffer() or for the wait to be interrupted
+ * by one of the timeouts established above.
+ */
ProcWaitForSignal(PG_WAIT_BUFFER_PIN);
- if (got_standby_deadlock_timeout)
+ if (got_standby_delay_timeout)
+ SendRecoveryConflictWithBufferPin(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN);
+ else if (got_standby_deadlock_timeout)
{
/*
* Send out a request for hot-standby backends to check themselves for
@@ -622,6 +628,7 @@ ResolveRecoveryConflictWithBufferPin(void)
* individually, but that'd be slower.
*/
disable_all_timeouts(false);
+ got_standby_delay_timeout = false;
got_standby_deadlock_timeout = false;
}
@@ -681,8 +688,8 @@ CheckRecoveryConflictDeadlock(void)
*/
/*
- * StandbyDeadLockHandler() will be called if STANDBY_DEADLOCK_TIMEOUT
- * occurs before STANDBY_TIMEOUT.
+ * StandbyDeadLockHandler() will be called if STANDBY_DEADLOCK_TIMEOUT is
+ * exceeded.
*/
void
StandbyDeadLockHandler(void)
@@ -692,16 +699,11 @@ StandbyDeadLockHandler(void)
/*
* StandbyTimeoutHandler() will be called if STANDBY_TIMEOUT is exceeded.
- * Send out a request to release conflicting buffer pins unconditionally,
- * so we can press ahead with applying changes in recovery.
*/
void
StandbyTimeoutHandler(void)
{
- /* forget any pending STANDBY_DEADLOCK_TIMEOUT request */
- disable_timeout(STANDBY_DEADLOCK_TIMEOUT, false);
-
- SendRecoveryConflictWithBufferPin(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN);
+ got_standby_delay_timeout = true;
}
/*
--
2.35.1.677.gabf474a5dd
--ijiwrbjbttsgn7hm
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="vREL_10_STABLE-0002-Backpatch-031_recovery_conflict.pl.patch"
view thread (7+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH vREL_10_STABLE 1/2] Fix possibility of self-deadlock in ResolveRecoveryConflictWithBufferPin().
In-Reply-To: <no-message-id-1859983@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox