pgsql: Respect changing pin limits in read_stream.c.

From: Thomas Munro <tmunro(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Respect changing pin limits in read_stream.c.
Date: 2025-03-14 08:24:35
Message-ID: E1tt0LL-002PfL-2z@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Respect changing pin limits in read_stream.c.

To avoid pinning too much of the buffer pool at once, read_stream.c
previously used LimitAdditionalPins(). The coding was naive, and only
considered the available buffers at stream construction time.

This commit checks before each StartReadBuffers() call with
GetAdditionalPinLimit(). The result might change over time due to pins
acquired outside this stream by the same backend. No extra CPU cycles
are added to the all-buffered fast-path code, but the I/O-starting path
now considers the up-to-date remaining buffer limit.

In practice it was quite difficult to exceed limits and cause any real
problems in v17, so no back-patch for now, but proposed changes will
make it easier.

Per code review from Andres, in the course of testing his AIO patches.

Reviewed-by: Andres Freund <andres(at)anarazel(dot)de> (earlier versions)
Discussion: https://postgr.es/m/CA%2BhUKGK_%3D4CVmMHvsHjOVrK6t4F%3DLBpFzsrr3R%2BaJYN8kcTfWg%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/92fc6856cb4c598f99c58b862bc34aebc6f2ec25

Modified Files
--------------
src/backend/storage/aio/read_stream.c | 106 +++++++++++++++++++++++++++++-----
1 file changed, 90 insertions(+), 16 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Álvaro Herrera 2025-03-14 08:29:35 pgsql: Remove direct handling of reloptions for toast tables
Previous Message Peter Eisentraut 2025-03-14 08:01:31 pgsql: Activate Python "Limited API" in PL/Python