Fix off-by-one in LimitAdditionalPins()
authorAndres Freund <[email protected]>
Tue, 25 Jul 2023 02:07:52 +0000 (19:07 -0700)
committerAndres Freund <[email protected]>
Tue, 25 Jul 2023 02:11:51 +0000 (19:11 -0700)
commitbd2f46c6559ddcafe7bae5015ac45b69bc014067
tree1d226216b69fa833b9cf5c142a9608d396a21703
parentb1dc946eee3d8d4fd9776ccbc21bcb4ab747b998
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" <[email protected]>
Reported-by: "Anton A. Melnikov" <[email protected]>
Reported-by: Victoria Shepard
Discussion: https://postgr.es/m/ae46f2fb-5586-3de0-b54b-1bb0f6410ebd@inbox.ru
Backpatch: 16-
src/backend/storage/buffer/bufmgr.c