Re: How to best find unexpected WARNINGs in the TAP tests?

From: Andres Freund <andres(at)anarazel(dot)de>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: How to best find unexpected WARNINGs in the TAP tests?
Date: 2026-08-24 12:42:59
Message-ID: 4og447tr2fb7nav2z3xtohd4kygazf25luqzevw3qgzkoauvx7@ga5f7wk3eeks
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2026-08-25 00:27:27 +1200, David Rowley wrote:
> In [1] there was a report about 39dcfda2d introducing a resource leak
> due to some missed table_close() calls. The 013_partition.pl triggered
> the issue, but we didn't get to find out about it because of how TAP
> tests work. A pg_regress test would fail as the psql output would show
> the WARNING, and we'd catch that with the diff against the expected
> result. With TAP, we don't do diffs like that, so this issue went
> unnoticed for (a rather embarrassing) 10 months.

I've always hated the fact these (and the aset.c etc "you corrupted memory"
ones) are WARNINGs, despite there clearly having been something bad to get to
that point.

Personally I regularly turn these kind of warnings into PANICs when working on
related code, as that's the only way to actually somewhat reliably be able to
find and debug problems.

> Another idea I thought about was to do:
>
> #ifdef USE_ASSERT_CHECKING
> #define BUG_WARNING ERROR
> #else
> #define BUG_WARNING WARNING
> #endif
>
> Then use BUG_WARNING in a select few places where we still want a
> WARNING in production builds, but we'd really like never to miss any
> of these in debug builds.

I'm not sure it's actually ok to use ERROR in all of these, because some of it
gets invoked in places like transaction abort that might not like getting
jumped out from willy-nilly.

> The attached patch does this and replaces a few WARNINGS with
> BUG_WARNING. This is only for the purpose of assisting discussion.

> The changes I made in the memory context code are a little strange as we
> only compile those functions in MEMORY_CONTEXT_CHECKING builds. I suspect
> these are WARNINGs today rather than ERRORs so we get a full damage report
> rather than just the first one.

Maybe, and I wouldn't be against emitting WARNINGs for anything we found and
then PANICing. But just carrying on with a WARNING continues to makes me feel
insane, 15+ years in.

> One annoying part of this is that to make test_resowner pass, I had to
> add not one, but two expected alternative outputs. I'm not yet quite
> clear on why the _2.out is needed. The order of the NOTICE and ERROR
> seems to alternate.

Huh. That seems like it needs some analysis.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Miłosz Bieniek 2026-08-24 12:53:50 Re: Apply worker can pick an invalid index for REPLICA IDENTITY FULL lookups
Previous Message Daniel Gustafsson 2026-08-24 12:36:06 Re: [PATCH] Several refactorings for pg_dump