Thread: pgsql: Emit invalidations to standby for transactions without xid.

pgsql: Emit invalidations to standby for transactions without xid.

From
Andres Freund
Date:
Emit invalidations to standby for transactions without xid.

So far, when a transaction with pending invalidations, but without an
assigned xid, committed, we simply ignored those invalidation
messages. That's problematic, because those are actually sent for a
reason.

Known symptoms of this include that existing sessions on a hot-standby
replica sometimes fail to notice new concurrently built indexes and
visibility map updates.

The solution is to WAL log such invalidations in transactions without an
xid. We considered to alternatively force-assign an xid, but that'd be
problematic for vacuum, which might be run in systems with few xids.

Important: This adds a new WAL record, but as the patch has to be
back-patched, we can't bump the WAL page magic. This means that standbys
have to be updated before primaries; otherwise
"PANIC: standby_redo: unknown op code 32" errors can be encountered.

XXX:

Reported-By: Васильев Дмитрий, Masahiko Sawada
Discussion:
    CAB-SwXY6oH=9twBkXJtgR4UC1NqT-vpYAtxCseME62ADwyK5OA@mail.gmail.com
    CAD21AoDpZ6Xjg=gFrGPnSn4oTRRcwK1EBrWCq9OqOHuAcMMC=w@mail.gmail.com

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/c6ff84b06a68b71719aa1aaa5f6704d8db1b51f8

Modified Files
--------------
src/backend/access/rmgrdesc/standbydesc.c       | 54 +++++++++++++++++++++++++
src/backend/access/rmgrdesc/xactdesc.c          | 30 ++------------
src/backend/access/transam/xact.c               | 18 +++++++++
src/backend/replication/logical/decode.c        |  9 +++++
src/backend/replication/logical/reorderbuffer.c | 53 +++++++++++++++---------
src/backend/storage/ipc/standby.c               | 35 ++++++++++++++++
src/backend/utils/cache/inval.c                 |  5 ++-
src/include/replication/reorderbuffer.h         |  2 +
src/include/storage/standby.h                   |  2 +
src/include/storage/standbydefs.h               | 21 ++++++++++
10 files changed, 181 insertions(+), 48 deletions(-)


Re: pgsql: Emit invalidations to standby for transactions without xid.

From
Andres Freund
Date:
Hi,

On 2016-04-27 03:35:56 +0000, Andres Freund wrote:
> Emit invalidations to standby for transactions without xid.

Damnit.  I shouldn't have worked on this while tired.  I wanted to
rebase to remove this commit after performing my testing for
http://archives.postgresql.org/message-id/E1avGGa-0007I0-Ua%40gemulon.postgresql.org
. But I somehow only removed the testing commit.

Now that I pushed it, I'm inclined to leave this in. Afaik the only
thing Michael's review has found is one typo and one copy-pasto. But
Simon didn't comment yet on whether he agreed on this path, Simon?

I'm planning, independent of whether people vote for reverting this till
then, on making a backpatchable version of this commit.

Andres