Re: Adding some error context for lock wait failures
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Dilip Kumar <dilipbalaut@gmail.com>, Zhang Mingli <zmlpostgres@gmail.com>, pgsql-hackers@lists.postgresql.org, Steve Baldwin <steve.baldwin@gmail.com>
Date: 2025-10-09T16:55:12Z
Lists: pgsql-hackers
Hi,
On 2025-10-09 12:50:53 -0400, Tom Lane wrote:
> I wrote:
> > Yeah. I see that errfinish does FreeErrorDataContents in the
> > non-ERROR code path, but of course that does nothing for random
> > leakages during error processing. I'm tempted to have it do
> > MemoryContextReset(ErrorContext) if we are at stack depth zero.
> > That'd be unsafe during nested error processing, but there
> > should not be anything of interest leftover once we're out
> > of the nest.
>
> Concretely, like the attached. This passes check-world, but
> I can't test it under valgrind because I'm hitting the same
> CREATE DATABASE failure skink is reporting.
Sorry, was working on a fix when life rudely intervened. Here's a quick
temporary fix:
diff --git i/src/backend/storage/buffer/bufmgr.c w/src/backend/storage/buffer/bufmgr.c
index d69e08ae61e..51c21e2ee06 100644
--- i/src/backend/storage/buffer/bufmgr.c
+++ w/src/backend/storage/buffer/bufmgr.c
@@ -3325,6 +3325,9 @@ TrackNewBufferPin(Buffer buf)
ref->refcount++;
ResourceOwnerRememberBuffer(CurrentResourceOwner, buf);
+
+ VALGRIND_MAKE_MEM_DEFINED(BufHdrGetBlock(GetBufferDescriptor(buf - 1)), BLCKSZ);
+
}
#define ST_SORT sort_checkpoint_bufferids
Greetings,
Andres Freund
Commits
-
Clean up memory leakage that occurs in context callback functions.
- 89d57c1fb355 19 (unreleased) landed
-
Provide error context when an error is thrown within WaitOnLock().
- f727b63e8107 19 (unreleased) landed