Re: Adding some error context for lock wait failures

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Zhang Mingli <zmlpostgres(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Steve Baldwin <steve(dot)baldwin(at)gmail(dot)com>
Subject: Re: Adding some error context for lock wait failures
Date: 2025-10-09 16:55:12
Message-ID: zldbjeb7exalzmfyro3g2lgo2n524wbraeiwwrmyi7q2yz6je4@ewgj63pyscml
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2025-10-09 17:07:22 Re: Invalid pointer access in logical decoding after error
Previous Message Tom Lane 2025-10-09 16:50:53 Re: Adding some error context for lock wait failures