aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/storage/buffer/bufmgr.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index e1e6240fe3e..a68eae81695 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -3273,6 +3273,20 @@ LockBufferForCleanup(Buffer buffer)
else
ProcWaitForSignal();
+ /*
+ * Remove flag marking us as waiter. Normally this will not be set
+ * anymore, but ProcWaitForSignal() can return for other signals as
+ * well. We take care to only reset the flag if we're the waiter, as
+ * theoretically another backend could have started waiting. That's
+ * impossible with the current usages due to table level locking, but
+ * better be safe.
+ */
+ LockBufHdr(bufHdr);
+ if ((bufHdr->flags & BM_PIN_COUNT_WAITER) != 0 &&
+ bufHdr->wait_backend_pid == MyProcPid)
+ bufHdr->flags &= ~BM_PIN_COUNT_WAITER;
+ UnlockBufHdr(bufHdr);
+
PinCountWaitBuf = NULL;
/* Loop back and try again */
}