From 3d3b8872814362e061802703bb5d92fe050fc602 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 15 Jul 2026 13:24:00 -0400 Subject: [PATCH] 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 Author: Thomas Munro Reviewed-by: Tom Lane Discussion: https://postgr.es/m/19551-d4a55b8fe81db4f2@postgresql.org Backpatch-through: 17 only --- src/backend/storage/aio/read_stream.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backend/storage/aio/read_stream.c b/src/backend/storage/aio/read_stream.c index 4c3218846dd..f9152ca084b 100644 --- a/src/backend/storage/aio/read_stream.c +++ b/src/backend/storage/aio/read_stream.c @@ -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