Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 12e28aa

Browse files
committed
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
1 parent 5f0adec commit 12e28aa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/backend/storage/ipc/latch.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ InitSharedLatch(Latch *latch)
402402
void
403403
OwnLatch(Latch *latch)
404404
{
405+
int owner_pid;
406+
405407
/* Sanity checks */
406408
Assert(latch->is_shared);
407409

@@ -410,8 +412,9 @@ OwnLatch(Latch *latch)
410412
Assert(selfpipe_readfd >= 0 && selfpipe_owner_pid == MyProcPid);
411413
#endif
412414

413-
if (latch->owner_pid != 0)
414-
elog(ERROR, "latch already owned");
415+
owner_pid = latch->owner_pid;
416+
if (owner_pid != 0)
417+
elog(PANIC, "latch already owned by PID %d", owner_pid);
415418

416419
latch->owner_pid = MyProcPid;
417420
}

0 commit comments

Comments
 (0)