From: | Dilip Kumar <dilipbalaut(at)gmail(dot)com> |
---|---|
To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | Ajin Cherian <itsajin(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [HACKERS] logical decoding of two-phase transactions |
Date: | 2020-09-30 09:16:13 |
Message-ID: | CAFiTN-sjAJ6mHpUJYCqiHF6-8+u-6sQWHQg5dUEH8LhdeASNwg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Sep 30, 2020 at 2:36 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Tue, Sep 29, 2020 at 8:04 PM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
> >
> > I have started looking into you latest patches, as of now I have a
> > few comments.
> >
> > v6-0001
> >
> > @@ -1987,7 +2072,7 @@ ReorderBufferProcessTXN(ReorderBuffer *rb,
> > ReorderBufferTXN *txn,
> > prev_lsn = change->lsn;
> >
> > /* Set the current xid to detect concurrent aborts. */
> > - if (streaming)
> > + if (streaming || rbtxn_prepared(change->txn))
> > {
> > curtxn = change->txn;
> > SetupCheckXidLive(curtxn->xid);
> > @@ -2249,7 +2334,6 @@ ReorderBufferProcessTXN(ReorderBuffer *rb,
> > ReorderBufferTXN *txn,
> > break;
> > }
> > }
> > -
> >
> > For streaming transaction we need to check the xid everytime because
> > there could concurrent a subtransaction abort, but
> > for two-phase we don't need to call SetupCheckXidLive everytime,
> > because we are sure that transaction is going to be
> > the same throughout the processing.
> >
>
> While decoding transactions at 'prepare' time there could be multiple
> sub-transactions like in the case below. Won't that be impacted if we
> follow your suggestion here?
>
> postgres=# Begin;
> BEGIN
> postgres=*# insert into t1 values(1,'aaa');
> INSERT 0 1
> postgres=*# savepoint s1;
> SAVEPOINT
> postgres=*# insert into t1 values(2,'aaa');
> INSERT 0 1
> postgres=*# savepoint s2;
> SAVEPOINT
> postgres=*# insert into t1 values(3,'aaa');
> INSERT 0 1
> postgres=*# Prepare Transaction 'foo';
> PREPARE TRANSACTION
But once we prepare the transaction, we can not rollback individual
subtransaction. We can only rollback the main transaction so instead
of setting individual subxact as CheckXidLive, we can just set the
main XID so no need to check on every command. Just set it before
start processing.
--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2020-09-30 09:30:31 | Re: Logical replication CPU-bound with TRUNCATE/DROP/CREATE many tables |
Previous Message | Amit Kapila | 2020-09-30 09:10:41 | Re: Resetting spilled txn statistics in pg_stat_replication |