v10-0001-Assert-that-all-fastpath-locks-are-released-befo.patch
text/x-patch
Filename: v10-0001-Assert-that-all-fastpath-locks-are-released-befo.patch
Type: text/x-patch
Part: 0
Patch
Format: format-patch
Series: patch v10-0001
Subject: Assert that all fastpath locks are released before exiting
| File | + | − |
|---|---|---|
| src/backend/storage/lmgr/proc.c | 15 | 21 |
From 5a4a2ea67b79e8cd3e1349fda4a103a63d81ef21 Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Mon, 19 Jan 2026 16:03:02 +0200
Subject: [PATCH v10 1/5] Assert that all fastpath locks are released before
exiting
---
src/backend/storage/lmgr/proc.c | 36 ++++++++++++++-------------------
1 file changed, 15 insertions(+), 21 deletions(-)
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 063826ae576..cb19b2c1169 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -498,13 +498,11 @@ InitProcess(void)
MyProc->waitProcLock = NULL;
pg_atomic_write_u64(&MyProc->waitStart, 0);
#ifdef USE_ASSERT_CHECKING
- {
- int i;
-
- /* Last process should have released all locks. */
- for (i = 0; i < NUM_LOCK_PARTITIONS; i++)
- Assert(dlist_is_empty(&(MyProc->myProcLocks[i])));
- }
+ /* Last process should have released all locks. */
+ for (int i = 0; i < NUM_LOCK_PARTITIONS; i++)
+ Assert(dlist_is_empty(&(MyProc->myProcLocks[i])));
+ for (uint32 g = 0; g < FastPathLockGroupsPerBackend; g++)
+ Assert(MyProc->fpLockBits[g] == 0);
#endif
MyProc->recoveryConflictPending = false;
@@ -694,13 +692,11 @@ InitAuxiliaryProcess(void)
MyProc->waitProcLock = NULL;
pg_atomic_write_u64(&MyProc->waitStart, 0);
#ifdef USE_ASSERT_CHECKING
- {
- int i;
-
- /* Last process should have released all locks. */
- for (i = 0; i < NUM_LOCK_PARTITIONS; i++)
- Assert(dlist_is_empty(&(MyProc->myProcLocks[i])));
- }
+ /* Last process should have released all locks. */
+ for (int i = 0; i < NUM_LOCK_PARTITIONS; i++)
+ Assert(dlist_is_empty(&(MyProc->myProcLocks[i])));
+ for (uint32 g = 0; g < FastPathLockGroupsPerBackend; g++)
+ Assert(MyProc->fpLockBits[g] == 0);
#endif
/*
@@ -936,13 +932,11 @@ ProcKill(int code, Datum arg)
SyncRepCleanupAtProcExit();
#ifdef USE_ASSERT_CHECKING
- {
- int i;
-
- /* Last process should have released all locks. */
- for (i = 0; i < NUM_LOCK_PARTITIONS; i++)
- Assert(dlist_is_empty(&(MyProc->myProcLocks[i])));
- }
+ /* All locks should be released before exiting. */
+ for (int i = 0; i < NUM_LOCK_PARTITIONS; i++)
+ Assert(dlist_is_empty(&(MyProc->myProcLocks[i])));
+ for (uint32 g = 0; g < FastPathLockGroupsPerBackend; g++)
+ Assert(MyProc->fpLockBits[g] == 0);
#endif
/*
--
2.47.3