Hi,

On Wed, Nov18, 2026 at 06:47 AM Melanie Plageman wrote:
On Tue, Nov 17, 2026 at 10:21 AM Zhijie Hou <[email protected]> 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


Reply via email to