12.04.2024 08:05, Alexander Lakhin wrote:
2024-04-12 05:00:17.981 UTC [762336] PANIC: stuck spinlock detected at WaitBufHdrUnlocked, bufmgr.c:5726
It looks like that spinlock issue caused by a race condition/deadlock. What I see when the test fails is: A client backend executing "DROP DATABASE conflict_db" performs dropdb() -> DropDatabaseBuffers() -> InvalidateBuffer() At the same time, bgwriter performs (for the same buffer): BgBufferSync() -> SyncOneBuffer() When InvalidateBuffer() is called, the buffer refcount is zero, then bgwriter pins the buffer, thus increases refcount; InvalidateBuffer() gets into the retry loop; bgwriter calls UnpinBuffer() -> UnpinBufferNoOwner() -> WaitBufHdrUnlocked(), which waits for !BM_LOCKED state, while InvalidateBuffer() waits for the buffer refcount decrease. As it turns out, it's not related to spinlocks' specifics or PRNG, just a serendipitous find. Best regards, Alexander