agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Melanie Plageman <melanieplageman@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make local buffers pin limit more conservative
Date: Tue, 21 Apr 2026 15:05:30 +0000
Message-ID: <E1wFCfJ-0021Te-2b@gemulon.postgresql.org> (raw)

Make local buffers pin limit more conservative

GetLocalPinLimit() and GetAdditionalLocalPinLimit(), currently in use
only by the read stream, previously allowed a backend to pin all
num_temp_buffers local buffers. This meant that the read stream could
use every available local buffer for read-ahead, leaving none for other
concurrent pin-holders like other read streams and related buffers like
the visibility map buffer needed during on-access pruning.

This became more noticeable since b46e1e54d07, which allows on-access
pruning to set the visibility map, which meant that some scans also
needed to pin a page of the VM. It caused a test in
src/test/regress/sql/temp.sql to fail in some cases.

Cap the local pin limit to num_temp_buffers / 4, providing some
headroom. This doesn't guarantee that all needed pins will be available
— for example, a backend can still open more cursors than there are
buffers — but it makes it less likely that read-ahead will exhaust the
pool.

Note that these functions are not limited by definition to use in the
read stream; however, this cap should be appropriate in other contexts.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/97529f5a-ec10-46b1-ab50-4653126c6889%40gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/da6874635db2e8ab95150481c992f03ec6094805

Modified Files
--------------
src/backend/storage/buffer/localbuf.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1wFCfJ-0021Te-2b@gemulon.postgresql.org>
Permalink:  ../E1wFCfJ-0021Te-2b@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wFCfJ-0021Te-2b@gemulon.postgresql.org

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: pgsql-committers@postgresql.org
  Cc: melanieplageman@gmail.com, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Make local buffers pin limit more conservative
  In-Reply-To: <E1wFCfJ-0021Te-2b@gemulon.postgresql.org>

* 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