Re: Potential hot-standby bug around xacts committed but in xl_running_xacts

From: Andres Freund <andres(at)anarazel(dot)de>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Petr Jelinek <petr(at)2ndquadrant(dot)com>
Subject: Re: Potential hot-standby bug around xacts committed but in xl_running_xacts
Date: 2017-05-02 16:06:18
Message-ID: 20170502160618.gdh2cgn5mgbh5mjr@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2017-05-02 07:12:41 +0200, Simon Riggs wrote:
> /*
> * The running-xacts snapshot can contain xids that were still visible
> * in the procarray when the snapshot was taken, but were already
> * WAL-logged as completed. They're not running anymore, so ignore
> * them.
> */
> if (TransactionIdDidCommit(xid) || TransactionIdDidAbort(xid))
> continue;

Ah, right. Phew ;)

> What I suggest is that with logical decoding in mind we do this
> 1. Inject a new record XLOG_SNAPSHOT_START at the start of
> LogStandbySnapshot(). We start logical decoding from there.
> 2. Record any transactions that end
> 3. Now the full XLOG_RUNNING_XACTS record arrives. We apply all xacts
> that are seen as running, minus any ended between 1 and 3

> This avoids the problems for the race but without holding locks while
> we log XLOG_RUNNING_XACTS, something that was considered painful for
> Hot Standby.

I don't think that really solves it, because other transactions could
just be stuck just after the XLogInsert() forever. And it'd have the
issue of having to backpatch a new record. I'm working on an
alternative approach, let's hope that that works out.

- Andres

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Petr Jelinek 2017-05-02 16:16:27 Re: logical replication syntax (was DROP SUBSCRIPTION, query cancellations and slot handling)
Previous Message Rahila Syed 2017-05-02 16:03:03 Re: Adding support for Default partition in partitioning