Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 09f8bb5

Browse files
committed
Revert unintentional change in increasing usage count during pin of buffers,
this makes buffer access strategy have no effect. Change was a part of commit 4835458 during 9.6 release cycle, so backpath to 9.6 Reported-by: Jim Nasby Author: Alexander Korotkov Reviewed-by: Jim Nasby, Andres Freund https://commitfest.postgresql.org/13/1029/
1 parent 09079b7 commit 09f8bb5

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/backend/storage/buffer/bufmgr.c

+15-3
Original file line numberDiff line numberDiff line change
@@ -1595,9 +1595,21 @@ PinBuffer(BufferDesc *buf, BufferAccessStrategy strategy)
15951595
/* increase refcount */
15961596
buf_state += BUF_REFCOUNT_ONE;
15971597

1598-
/* increase usagecount unless already max */
1599-
if (BUF_STATE_GET_USAGECOUNT(buf_state) != BM_MAX_USAGE_COUNT)
1600-
buf_state += BUF_USAGECOUNT_ONE;
1598+
if (strategy == NULL)
1599+
{
1600+
/* Default case: increase usagecount unless already max. */
1601+
if (BUF_STATE_GET_USAGECOUNT(buf_state) < BM_MAX_USAGE_COUNT)
1602+
buf_state += BUF_USAGECOUNT_ONE;
1603+
}
1604+
else
1605+
{
1606+
/*
1607+
* Ring buffers shouldn't evict others from pool. Thus we
1608+
* don't make usagecount more than 1.
1609+
*/
1610+
if (BUF_STATE_GET_USAGECOUNT(buf_state) == 0)
1611+
buf_state += BUF_USAGECOUNT_ONE;
1612+
}
16011613

16021614
if (pg_atomic_compare_exchange_u32(&buf->state, &old_buf_state,
16031615
buf_state))

0 commit comments

Comments
 (0)