Re: Logical decoding restart problems

Поиск
Список
Период
Сортировка
От Stas Kelvich
Тема Re: Logical decoding restart problems
Дата
Msg-id 45164FA8-9F79-4101-87F4-A65AACDB03E4@postgrespro.ru
обсуждение исходный текст
Ответ на Re: Logical decoding restart problems  (Craig Ringer <craig@2ndquadrant.com>)
Ответы Re: Logical decoding restart problems  (Craig Ringer <craig@2ndquadrant.com>)
Список pgsql-hackers
> On 20 Aug 2016, at 15:59, Craig Ringer <craig@2ndquadrant.com> wrote:
>
> I'll wait for a test case or some more detail.

Thanks for clarification about how restart_lsn is working.

Digging slightly deeper into this topic revealed that problem was in two phase decoding, not it logical decoding
itself.
While I was writing DecodePrepare() I've and copied call to SnapBuildCommitTxn() function from DecodeCommit()
which was removing current transaction from running list and that’s obviously wrong thing to do for a prepared tx.

So I end up with following workaround:

--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -950,7 +950,7 @@ SnapBuildAbortTxn(SnapBuild *builder, XLogRecPtr lsn, */voidSnapBuildCommitTxn(SnapBuild *builder,
XLogRecPtrlsn, TransactionId xid, 
-                                  int nsubxacts, TransactionId *subxacts)
+                                  int nsubxacts, TransactionId *subxacts, bool isCommit){       int
nxact; 
@@ -1026,7 +1026,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,        * Make sure
topleveltxn is not tracked in running txn's anymore, switch        * state to consistent if possible.        */ 
-       SnapBuildEndTxn(builder, lsn, xid);
+       if (isCommit)
+               SnapBuildEndTxn(builder, lsn, xid);


Calling SnapBuildCommitTxn with isCommit=true from commit and false from Prepare. However while I’m not
observing partially decoded transactions anymore, I’m not sure that this is right way to build proper snapshot and
something else isn’t broken.

Also while I was playing psycopg2 logical decoding client I do see empty transaction containing only
BEGIN/COMMIT (with test_decoding output plugin, and current postgres master).


--
Stas Kelvich
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Gerdan Santos
Дата:
Сообщение: Re: \timing interval
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: patch proposal