diff options
author | Andres Freund <andres@anarazel.de> | 2023-07-24 19:07:52 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2023-07-24 19:11:51 -0700 |
commit | bd2f46c6559ddcafe7bae5015ac45b69bc014067 (patch) | |
tree | 1d226216b69fa833b9cf5c142a9608d396a21703 /src | |
parent | b1dc946eee3d8d4fd9776ccbc21bcb4ab747b998 (diff) | |
download | postgresql-bd2f46c6559ddcafe7bae5015ac45b69bc014067.tar.gz postgresql-bd2f46c6559ddcafe7bae5015ac45b69bc014067.zip |
Fix off-by-one in LimitAdditionalPins()
Due to the bug LimitAdditionalPins() could return 0, violating
LimitAdditionalPins()'s API ("One additional pin is always allowed"). This
could be hit when setting shared_buffers very low and using a fair amount of
concurrency.
This bug was introduced in 31966b151e6a.
Author: "Anton A. Melnikov" <aamelnikov@inbox.ru>
Reported-by: "Anton A. Melnikov" <aamelnikov@inbox.ru>
Reported-by: Victoria Shepard
Discussion: https://postgr.es/m/ae46f2fb-5586-3de0-b54b-1bb0f6410ebd@inbox.ru
Backpatch: 16-
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/storage/buffer/bufmgr.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 3c59bbd04ea..bd203c21913 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -1767,7 +1767,7 @@ LimitAdditionalPins(uint32 *additional_pins) */ max_proportional_pins -= PrivateRefCountOverflowed + REFCOUNT_ARRAY_ENTRIES; - if (max_proportional_pins < 0) + if (max_proportional_pins <= 0) max_proportional_pins = 1; if (*additional_pins > max_proportional_pins) |