public inbox for [email protected]
help / color / mirror / Atom feedFrom: Daniel Gustafsson <[email protected]>
To: Andrei Lepikhov <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Flaky test in t/100_vacuumdb.pl: ordering assumption not stable under plan changes
Date: Fri, 3 Apr 2026 12:27:27 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
> On 3 Apr 2026, at 08:42, Andrei Lepikhov <[email protected]> wrote:
>
> Hi,
>
> I found that t/100_vacuumdb.pl has a fragile ordering check that fails if the query plan for vacuumdb's catalogue query changes. I sometimes see how this test fails when writing an optimisation-related extension.
>
> The test checks that vacuumdb processes "Foo".bar before "Bar".baz:
>
> qr/VACUUM\ \(SKIP_DATABASE_STATS\)\ "Foo".bar
> .*VACUUM\ \(SKIP_DATABASE_STATS\)\ "Bar".baz
> /sx,
>
> Both tables being tested, "Foo".bar and "Bar".baz, are created empty. This means pg_class.relpages is 0 for both and the sort order is completely unstable. The output order depends entirely on which query plan will be chosen. Any change in the planner that affects the plan for this query, such as a new join path type or a cost model change, may flip the order and cause the test to fail.
>
> AFAICS, The fix is quite trivial. Change the test regex (in 100_vacuumdb.pl) to use order-independent lookaheads instead of a sequential match:
>
> qr/(?=.*VACUUM\ \(SKIP_DATABASE_STATS\)\ "Foo"\.bar)
> (?=.*VACUUM\ \(SKIP_DATABASE_STATS\)\ "Bar"\.baz)
> /sx,
>
> This makes the test robust regardless of the order in which the server returns results.
>
> Hence, it doesn’t change anything important. I think it deserves to be back-patched down to v.16 (like the commit 2143d96dc7b introduced this test) so other extensions can be stable with check-world tests.
Thanks for the report, I'll have a look.
--
Daniel Gustafsson
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Flaky test in t/100_vacuumdb.pl: ordering assumption not stable under plan changes
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox