Skip to content

Commit

Permalink
Revert unintentional change in increasing usage count during pin of b…
Browse files Browse the repository at this point in the history
…uffers,

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/
  • Loading branch information
feodor committed Mar 20, 2017
1 parent 09079b7 commit 09f8bb5
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/backend/storage/buffer/bufmgr.c
Expand Up @@ -1595,9 +1595,21 @@ PinBuffer(BufferDesc *buf, BufferAccessStrategy strategy)
/* increase refcount */
buf_state += BUF_REFCOUNT_ONE;

/* increase usagecount unless already max */
if (BUF_STATE_GET_USAGECOUNT(buf_state) != BM_MAX_USAGE_COUNT)
buf_state += BUF_USAGECOUNT_ONE;
if (strategy == NULL)
{
/* Default case: increase usagecount unless already max. */
if (BUF_STATE_GET_USAGECOUNT(buf_state) < BM_MAX_USAGE_COUNT)
buf_state += BUF_USAGECOUNT_ONE;
}
else
{
/*
* Ring buffers shouldn't evict others from pool. Thus we
* don't make usagecount more than 1.
*/
if (BUF_STATE_GET_USAGECOUNT(buf_state) == 0)
buf_state += BUF_USAGECOUNT_ONE;
}

if (pg_atomic_compare_exchange_u32(&buf->state, &old_buf_state,
buf_state))
Expand Down

0 comments on commit 09f8bb5

Please sign in to comment.