diff options
author | Robert Haas <rhaas@postgresql.org> | 2024-03-14 08:55:25 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2024-03-14 08:56:06 -0400 |
commit | 2346df6fc373df9c5ab944eebecf7d3036d727de (patch) | |
tree | c31e8b08c92c01b7a3db2df378917362fe301391 /src/include/storage/proc.h | |
parent | c20d90a41ca869f9c6dd4058ad1c7f5c9ee9d912 (diff) | |
download | postgresql-2346df6fc373df9c5ab944eebecf7d3036d727de.tar.gz postgresql-2346df6fc373df9c5ab944eebecf7d3036d727de.zip |
Allow a no-wait lock acquisition to succeed in more cases.
We don't determine the position at which a process waiting for a lock
should insert itself into the wait queue until we reach ProcSleep(),
and we may at that point discover that we must insert ourselves ahead
of everyone who wants a conflicting lock, in which case we obtain the
lock immediately. Up until now, a no-wait lock acquisition would fail
in such cases, erroneously claiming that the lock couldn't be obtained
immediately. Fix that by trying ProcSleep even in the no-wait case.
No back-patch for now, because I'm treating this as an improvement to
the existing no-wait feature. It could instead be argued that it's a
bug fix, on the theory that there should never be any case whatsoever
where no-wait fails to obtain a lock that would have been obtained
immediately without no-wait, but I'm reluctant to interpret the
semantics of no-wait that strictly.
Robert Haas and Jingxian Li
Discussion: http://postgr.es/m/CA+TgmobCH-kMXGVpb0BB-iNMdtcNkTvcZ4JBxDJows3kYM+GDg@mail.gmail.com
Diffstat (limited to 'src/include/storage/proc.h')
-rw-r--r-- | src/include/storage/proc.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 1095aefddfe..18891a86fb9 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -471,7 +471,9 @@ extern int GetStartupBufferPinWaitBufId(void); extern bool HaveNFreeProcs(int n, int *nfree); extern void ProcReleaseLocks(bool isCommit); -extern ProcWaitStatus ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable); +extern ProcWaitStatus ProcSleep(LOCALLOCK *locallock, + LockMethod lockMethodTable, + bool dontWait); extern void ProcWakeup(PGPROC *proc, ProcWaitStatus waitStatus); extern void ProcLockWakeup(LockMethod lockMethodTable, LOCK *lock); extern void CheckDeadLockAlert(void); |