diff options
| author | Heikki Linnakangas | 2025-03-28 18:19:17 +0000 |
|---|---|---|
| committer | Heikki Linnakangas | 2025-03-28 18:19:17 +0000 |
| commit | 51a0382e8d8793b5cc89b69285e5ecdffe03c2bf (patch) | |
| tree | 792bb0e8b09ebb05d0df3b4da19853302f7ae207 /src/backend | |
| parent | 9ac6f7e7ceb6e7c9b168bbf02bbe4662782dfa6e (diff) | |
Fix crash if LockErrorCleanup() is called twice
The refactoring in commit 3c0fd64fec removed the clearing of
awaitedLock from LockErrorCleanup(). It's still needed, otherwise
LockErrorCleanup() during abort processing will try to update the
LOCALLOCK struct even after the lock has already been released. Put it
back.
Reported-by: Richard Guo <guofenglinux@gmail.com>
Reported-by: Robins Tharakan <tharakan@gmail.com>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAMbWs4_dNX1SzBmvFdoY-LxJh_4W_BjtVd5i008ihfU-wFF=eg@mail.gmail.com
Discussion: https://www.postgresql.org/message-id/18832-38e5575b1bbd7277@postgresql.org
Discussion: https://www.postgresql.org/message-id/e11a30e5-c0d8-491d-8546-3a1b50c10ad4@gmail.com
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/storage/lmgr/lock.c | 9 | ||||
| -rw-r--r-- | src/backend/storage/lmgr/proc.c | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 38a5d75bbe1..002303664aa 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -1897,6 +1897,15 @@ GetAwaitedLock(void) } /* + * ResetAwaitedLock -- Forget that we are waiting on a lock. + */ +void +ResetAwaitedLock(void) +{ + awaitedLock = NULL; +} + +/* * MarkLockClear -- mark an acquired lock as "clear" * * This means that we know we have absorbed all sinval messages that other diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index e4ca861a8e6..066319afe2b 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -814,6 +814,8 @@ LockErrorCleanup(void) GrantAwaitedLock(); } + ResetAwaitedLock(); + LWLockRelease(partitionLock); RESUME_INTERRUPTS(); |
