pgsql: Avoid WAL flush checks for unlogged buffers in GetVictimBuffer()

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid WAL flush checks for unlogged buffers in GetVictimBuffer()
Date: 2026-03-11 18:52:57
Message-ID: E1w0Ofx-003VZb-37@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid WAL flush checks for unlogged buffers in GetVictimBuffer()

GetVictimBuffer() rejects a victim buffer if it is from a bulkread
strategy ring and reusing it would require flushing WAL. Unlogged table
buffers can have fake LSNs (e.g. unlogged GiST pages) and calling
XLogNeedsFlush() on a fake LSN is meaningless.

This is a bit of future-proofing because currently the bulkread strategy
is not used for relations with fake LSNs.

Author: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Reported-by: Andres Freund <andres(at)anarazel(dot)de>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Earlier version reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://postgr.es/m/flat/fmkqmyeyy7bdpvcgkheb6yaqewemkik3ls6aaveyi5ibmvtxnd%40nu2kvy5rq3a6

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/11e0824bd97e1639f9358260f389083135e0b5e3

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2026-03-11 19:02:57 pgsql: bufmgr: Remove the, now obsolete, BM_JUST_DIRTIED
Previous Message Tomas Vondra 2026-03-11 18:48:07 pgsql: Do not lock in BufferGetLSNAtomic() on archs with 8 byte atomic