File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
src/backend/storage/buffer Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -1595,9 +1595,21 @@ PinBuffer(BufferDesc *buf, BufferAccessStrategy strategy)
1595
1595
/* increase refcount */
1596
1596
buf_state += BUF_REFCOUNT_ONE ;
1597
1597
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
+ }
1601
1613
1602
1614
if (pg_atomic_compare_exchange_u32 (& buf -> state , & old_buf_state ,
1603
1615
buf_state ))
You can’t perform that action at this time.
0 commit comments