Re: WAL_LOG CREATE DATABASE strategy broken for non-standard page layouts

From: Zhijie Hou <houzhijie22(at)gmail(dot)com>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Rogers Wang <rogers(dot)ww(at)qq(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: WAL_LOG CREATE DATABASE strategy broken for non-standard page layouts
Date: 2026-11-18 15:41:52
Message-ID: d977e2cc-6d18-49be-8e5b-de71360d82f8@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Nov18, 2026 at 06:47 AM Melanie Plageman wrote:
> On Tue, Nov 17, 2026 at 10:21 AM Zhijie Hou <houzhijie22(at)gmail(dot)com> wrote:
> >
> > I think we also need to increase shared_buffers (e.g., to 16MB),
> > because $node->init(allows_streaming => 1) sets shared_buffers to
> > 1MB internally, causing the pg_class pages to be evicted from
> > shared_buffers before CREATE TABLE runs, so the test could not reach
> > the old bug path.
>
> Ah, okay. I'll do that. The original test feels awfully fragile. Is
> there something we could do to strengthen it? Like check that one of
> the buffers is marked BM_PERMANENT somehow? It seems very trivial to
> accidentally eliminate the coverage. And there are of course lots of
> ways for those buffers to get evicted.
Maybe we could add a few comments above the CREATE DATABASE command to
give developers a hint, and if it's worth it, we could add a check after
the command to verify that pg_class's pages stay in the buffer cache
(But note that if we add this check, we'd better disable autovaccum to
prevent background access):

# Verify that scanning template1's pg_class performs zero disk reads,
# confirming its pages were not evicted by CREATE DATABASE.
is( $node->safe_psql(
$db_template, q{
SELECT pg_stat_get_xact_blocks_fetched('pg_class'::regclass) -
pg_stat_get_xact_blocks_hit('pg_class'::regclass)
FROM pg_class
HAVING sum(relpages) >= 0;
}),
"0",
"template pg_class pages remain cached after CREATE DATABASE");

--
Best Regards,
Zhijie Hou

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-11-18 15:42:01 Re: [RFC] An ETW backend for the static probes on Windows
Previous Message Tatsuya Kawata 2026-11-18 15:41:27 Report the peak total storage of Recursive Union nodes in EXPLAIN