summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Munro2022-05-30 23:38:19 +0000
committerThomas Munro2022-05-31 00:06:11 +0000
commit12e28aac8e8eb76cab13a4e9b696e3dab17f1c99 (patch)
treeb399c9e3729c4a476b6fd2f11e40b3c6183257db
parent5f0adec2537dab531ef63ff6e0fe640698a291d9 (diff)
Add debugging help in OwnLatch().
Build farm animal gharial recently failed a few times in a parallel worker's call to OwnLatch() with "ERROR: latch already owned". Let's turn that into a PANIC and show the PID of the owner, to try to learn more. Discussion: https://postgr.es/m/CA%2BhUKGJ_0RGcr7oUNzcHdn7zHqHSB_wLSd3JyS2YC_DYB%2B-V%3Dg%40mail.gmail.com
-rw-r--r--src/backend/storage/ipc/latch.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.c
index 78c6a89271..41d359d68e 100644
--- a/src/backend/storage/ipc/latch.c
+++ b/src/backend/storage/ipc/latch.c
@@ -402,6 +402,8 @@ InitSharedLatch(Latch *latch)
void
OwnLatch(Latch *latch)
{
+ int owner_pid;
+
/* Sanity checks */
Assert(latch->is_shared);
@@ -410,8 +412,9 @@ OwnLatch(Latch *latch)
Assert(selfpipe_readfd >= 0 && selfpipe_owner_pid == MyProcPid);
#endif
- if (latch->owner_pid != 0)
- elog(ERROR, "latch already owned");
+ owner_pid = latch->owner_pid;
+ if (owner_pid != 0)
+ elog(PANIC, "latch already owned by PID %d", owner_pid);
latch->owner_pid = MyProcPid;
}