summaryrefslogtreecommitdiff
path: root/src/backend/storage/lmgr/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage/lmgr/proc.c')
-rw-r--r--src/backend/storage/lmgr/proc.c74
1 files changed, 46 insertions, 28 deletions
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 46838d852e5..74ef4197986 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -42,6 +42,7 @@
#include "postmaster/autovacuum.h"
#include "replication/slot.h"
#include "replication/syncrep.h"
+#include "storage/standby.h"
#include "storage/ipc.h"
#include "storage/lmgr.h"
#include "storage/pmsignal.h"
@@ -1169,21 +1170,27 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
*
* If LockTimeout is set, also enable the timeout for that. We can save a
* few cycles by enabling both timeout sources in one call.
+ *
+ * If InHotStandby we set lock waits slightly later for clarity with other
+ * code.
*/
- if (LockTimeout > 0)
+ if (!InHotStandby)
{
- EnableTimeoutParams timeouts[2];
-
- timeouts[0].id = DEADLOCK_TIMEOUT;
- timeouts[0].type = TMPARAM_AFTER;
- timeouts[0].delay_ms = DeadlockTimeout;
- timeouts[1].id = LOCK_TIMEOUT;
- timeouts[1].type = TMPARAM_AFTER;
- timeouts[1].delay_ms = LockTimeout;
- enable_timeouts(timeouts, 2);
+ if (LockTimeout > 0)
+ {
+ EnableTimeoutParams timeouts[2];
+
+ timeouts[0].id = DEADLOCK_TIMEOUT;
+ timeouts[0].type = TMPARAM_AFTER;
+ timeouts[0].delay_ms = DeadlockTimeout;
+ timeouts[1].id = LOCK_TIMEOUT;
+ timeouts[1].type = TMPARAM_AFTER;
+ timeouts[1].delay_ms = LockTimeout;
+ enable_timeouts(timeouts, 2);
+ }
+ else
+ enable_timeout_after(DEADLOCK_TIMEOUT, DeadlockTimeout);
}
- else
- enable_timeout_after(DEADLOCK_TIMEOUT, DeadlockTimeout);
/*
* If somebody wakes us between LWLockRelease and WaitLatch, the latch
@@ -1201,15 +1208,23 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
*/
do
{
- WaitLatch(MyLatch, WL_LATCH_SET, 0);
- ResetLatch(MyLatch);
- /* check for deadlocks first, as that's probably log-worthy */
- if (got_deadlock_timeout)
+ if (InHotStandby)
+ {
+ /* Set a timer and wait for that or for the Lock to be granted */
+ ResolveRecoveryConflictWithLock(locallock->tag.lock);
+ }
+ else
{
- CheckDeadLock();
- got_deadlock_timeout = false;
+ WaitLatch(MyLatch, WL_LATCH_SET, 0);
+ ResetLatch(MyLatch);
+ /* check for deadlocks first, as that's probably log-worthy */
+ if (got_deadlock_timeout)
+ {
+ CheckDeadLock();
+ got_deadlock_timeout = false;
+ }
+ CHECK_FOR_INTERRUPTS();
}
- CHECK_FOR_INTERRUPTS();
/*
* waitStatus could change from STATUS_WAITING to something else
@@ -1447,18 +1462,21 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
* already caused QueryCancelPending to become set, we want the cancel to
* be reported as a lock timeout, not a user cancel.
*/
- if (LockTimeout > 0)
+ if (!InHotStandby)
{
- DisableTimeoutParams timeouts[2];
+ if (LockTimeout > 0)
+ {
+ DisableTimeoutParams timeouts[2];
- timeouts[0].id = DEADLOCK_TIMEOUT;
- timeouts[0].keep_indicator = false;
- timeouts[1].id = LOCK_TIMEOUT;
- timeouts[1].keep_indicator = true;
- disable_timeouts(timeouts, 2);
+ timeouts[0].id = DEADLOCK_TIMEOUT;
+ timeouts[0].keep_indicator = false;
+ timeouts[1].id = LOCK_TIMEOUT;
+ timeouts[1].keep_indicator = true;
+ disable_timeouts(timeouts, 2);
+ }
+ else
+ disable_timeout(DEADLOCK_TIMEOUT, false);
}
- else
- disable_timeout(DEADLOCK_TIMEOUT, false);
/*
* Re-acquire the lock table's partition lock. We have to do this to hold