pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix and test snapshot behavior on standby.
Date: Thu, 01 Oct 2020 00:31:45 +0000
Message-ID: <E1kNmVd-00070V-JC@gemulon.postgresql.org> (raw)

Fix and test snapshot behavior on standby.

I (Andres) broke this in 623a9CA79bx, because I didn't think about the
way snapshots are built on standbys sufficiently. Unfortunately our
existing tests did not catch this, as they are all just querying with
psql (therefore ending up with fresh snapshots).

The fix is trivial, we just need to increment the transaction
completion counter in ExpireTreeKnownAssignedTransactionIds(), which
is the equivalent of ProcArrayEndTransaction() during recovery.

This commit also adds a new test doing some basic testing of the
correctness of snapshots built on standbys. To avoid the
aforementioned issue of one-shot psql's not exercising the snapshot
caching, the test uses a long lived psqls, similar to
013_crash_restart.pl. It'd be good to extend the test further.

Reported-By: Ian Barwick <ian.barwick@2ndquadrant.com>
Author: Andres Freund <andres@anarazel.de>
Author: Ian Barwick <ian.barwick@2ndquadrant.com>
Discussion: https://postgr.es/m/61291ffe-d611-f889-68b5-c298da9fb18f@2ndquadrant.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7b28913bcab8d1bf3dbf59c9d8fb4b51cef57664

Modified Files
--------------
src/backend/storage/ipc/procarray.c       |   3 +
src/test/recovery/t/021_row_visibility.pl | 192 ++++++++++++++++++++++++++++++
2 files changed, 195 insertions(+)



Message-ID: <E1kNmVd-00070V-JC@gemulon.postgresql.org>
Permalink:  ../E1kNmVd-00070V-JC@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1kNmVd-00070V-JC@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: andres@anarazel.de
  Subject: Re: pgsql: Fix and test snapshot behavior on standby.
  In-Reply-To: <E1kNmVd-00070V-JC@gemulon.postgresql.org>
  References: <E1kNmVd-00070V-JC@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