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