aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2017-03-20 18:49:41 +0300
committerTeodor Sigaev <teodor@sigaev.ru>2017-03-20 18:49:41 +0300
commit09f8bb5b3617269eb750b395fb561a2e532af221 (patch)
tree33fb70f39507dcd1a0dfea3a0d8d04473398893f /src
parent09079b72b7fd354f9d18833bdb7ac15e9cc35a86 (diff)
downloadpostgresql-09f8bb5b3617269eb750b395fb561a2e532af221.tar.gz
postgresql-09f8bb5b3617269eb750b395fb561a2e532af221.zip
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 48354581a49c30f5757c203415aa8412d85b0f70 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/
Diffstat (limited to 'src')
-rw-r--r--src/backend/storage/buffer/bufmgr.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index a67fff69728..3a300305ecd 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -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))