1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

Make max_pinned_buffers be > 0, don't just Assert that it is.

It was possible to trigger read_stream_begin_relation's
assertion that it calculated nonzero max_pinned_buffers,
in scenarios with unreasonably small numbers of buffers.
There seems to be no visible problem in non-Assert builds.

The bug occurs only in v17 (the first branch containing
this logic), because commit 92fc6856c replaced that Assert
with a runtime clamp.  I won't risk back-patching that entire
commit, but let's copy just this minimal fix.

Bug: #19551
Reported-by: Roman Zharkov <r.zharkov@postgrespro.ru>
Author: Thomas Munro <thomas.munro@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19551-d4a55b8fe81db4f2@postgresql.org
Backpatch-through: 17 only
This commit is contained in:
Tom Lane
2026-07-15 13:24:00 -04:00
parent 2d1ed2c1dd
commit 3d3b887281

View File

@@ -470,7 +470,12 @@ read_stream_begin_relation(int flags,
LimitAdditionalLocalPins(&max_pinned_buffers);
else
LimitAdditionalPins(&max_pinned_buffers);
Assert(max_pinned_buffers > 0);
/*
* The limit might be zero on a system configured with too few buffers for
* the number of connections. We need at least one to make progress.
*/
max_pinned_buffers = Max(1, max_pinned_buffers);
/*
* We need one extra entry for buffers and per-buffer data, because users