From: | Simon Riggs <simon(at)2ndquadrant(dot)com> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
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 17:06:54 |
Message-ID: | CANP8+jKGdCTn0JKhNnM42s4DD3qxRxzGwEM0L+BsTjAAAjC=pA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2 May 2017 at 18:06, Andres Freund <andres(at)anarazel(dot)de> wrote:
>> 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.
Backpatchable approach.
1. Record CurrentInsertPosition()
2. LogStandbySnapshot()
3. Insert custom logical wal message containing currentinsertposition
and LSN of (2)
When we decode
1. Read standby snapshot
2. Scan forwards until we see message written by step (3) above, which
is identifiable because it contains LSN of snapshot.
3. Read initial LSN from message then re-scan from LSN until
xl_running_xacts message collecting any commits/aborts and removing
them from snapshot.
No new WAL messages, no locking problem, race condition handled.
--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2017-05-02 17:27:17 | Re: logical replication syntax (was DROP SUBSCRIPTION, query cancellations and slot handling) |
Previous Message | Tomas Vondra | 2017-05-02 17:05:10 | Re: CTE inlining |