pgsql: Fix two off-by-one errors in bufmgr.c.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix two off-by-one errors in bufmgr.c.
Date: 2015-08-12 15:37:30
Message-ID: E1ZPY5q-0000Nf-Os@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix two off-by-one errors in bufmgr.c.

In 4b4b680c I passed a buffer index number (starting from 0) instead of
a proper Buffer id (which start from 1 for shared buffers) in two
places.

This wasn't noticed so far as one of those locations isn't compiled at
all (PrintPinnedBufs) and the other one (InvalidBuffer) requires a
unlikely, but possible, set of circumstances to trigger a symptom.

To reduce the likelihood of such incidents a bit also convert existing
open coded mappings from buffer descriptors to buffer ids with
BufferDescriptorGetBuffer().

Author: Qingqing Zhou
Reported-By: Qingqing Zhou
Discussion: CAJjS0u2ai9ooUisKtkV8cuVUtEkMTsbK8c7juNAjv8K11zeCQg(at)mail(dot)gmail(dot)com
Backpatch: 9.5 where the private ref count infrastructure was introduced

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/43a8ed26c97e36d971b6018d1bc94ad5c52d169b

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c | 36 ++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2015-08-12 15:38:25 Re: pgsql: Optionally don't error out due to preexisting slots in commandli
Previous Message Andres Freund 2015-08-12 15:37:28 pgsql: Remove duplicated assignment in pg_create_physical_replication_s