postgres.git / summary / log / commit / refs

commit    bd2f46c6559ddcafe7bae5015ac45b69bc014067
Author:   Andres Freund <andres@anarazel.de>
Date:     Tue Jul 25 02:07:52 2023 +0000
First released in: 17.0, 16.0

    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-


src/backend/storage/buffer/bufmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) [parent: b1dc946eee3d]