pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@postgresql.org
Subject: pgsql: Change some bogus PageGetLSN calls to BufferGetLSNAtomic
Date: Tue, 09 Jan 2018 20:10:17 +0000
Message-ID: <E1eZ0Dx-0008OC-17@gemulon.postgresql.org> (raw)

Change some bogus PageGetLSN calls to BufferGetLSNAtomic

As src/backend/access/transam/README says, PageGetLSN may only be called
by processes holding either exclusive lock on buffer, or a shared lock
on buffer plus buffer header lock.  Therefore any place that only holds
a shared buffer lock must use BufferGetLSNAtomic instead of PageGetLSN,
which internally obtains buffer header lock prior to reading the LSN.

A few callsites failed to comply with this rule.  This was detected by
running all tests under a new (not committed) assertion that verifies
PageGetLSN locking contract.  All but one of the callsites that failed
the assertion are fixed by this patch.  Remaining callsites were
inspected manually and determined not to need any change.

The exception (unfixed callsite) is in TestForOldSnapshot, which only
has a Page argument, making it impossible to access the corresponding
Buffer from it.  Fixing that seems a much larger patch that will have to
be done separately; and that's just as well, since it was only
introduced in 9.6 and other bugs are much older.

Some of these bugs are ancient; backpatch all the way back to 9.3.

Authors: Jacob Champion, Asim Praveen, Ashwin Agrawal
Reviewed-by: Michaƫl Paquier
Discussion: https://postgr.es/m/CABAq_6GXgQDVu3u12mK9O5Xt5abBZWQ0V40LZCE+oUf95XyNFg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/272c2ab9fd0a604e3200030b1ea26fd464c44935

Modified Files
--------------
src/backend/access/gist/gist.c        | 5 +++--
src/backend/access/gist/gistget.c     | 4 ++--
src/backend/access/gist/gistvacuum.c  | 2 +-
src/backend/access/nbtree/nbtsearch.c | 2 +-
src/backend/access/nbtree/nbtutils.c  | 2 +-
5 files changed, 8 insertions(+), 7 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1eZ0Dx-0008OC-17@gemulon.postgresql.org>
Permalink:  ../E1eZ0Dx-0008OC-17@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1eZ0Dx-0008OC-17@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Change some bogus PageGetLSN calls to BufferGetLSNAtomic
  In-Reply-To: <E1eZ0Dx-0008OC-17@gemulon.postgresql.org>
  References: <E1eZ0Dx-0008OC-17@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox