Re: [HACKERS] logical decoding of two-phase transactions

From: Ajin Cherian <itsajin(at)gmail(dot)com>
To: "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>
Cc: Peter Smith <smithpb2250(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Greg Nancarrow <gregn4422(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] logical decoding of two-phase transactions
Date: 2021-07-06 11:18:18
Message-ID: CAFPTHDZyffPtB4McWf8VU2of2C3qEKwJdzkKCm54=cUu_ZWZuw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 2, 2021 at 8:18 PM tanghy(dot)fnst(at)fujitsu(dot)com
<tanghy(dot)fnst(at)fujitsu(dot)com> wrote:
>
> Thanks for your patch. I met an issue while using it. When a transaction contains TRUNCATE, the subscriber reported an error: " ERROR: no data left in message" and the data couldn't be replicated.
>
> Steps to reproduce the issue:
>
> (set logical_decoding_work_mem to 64kB at publisher so that streaming could work. )
>
> ------publisher------
> create table test (a int primary key, b varchar);
> create publication pub for table test;
>
> ------subscriber------
> create table test (a int primary key, b varchar);
> create subscription sub connection 'dbname=postgres' publication pub with(two_phase=on, streaming=on);
>
> ------publisher------
> BEGIN;
> TRUNCATE test;
> INSERT INTO test SELECT i, md5(i::text) FROM generate_series(1001, 6000) s(i);
> UPDATE test SET b = md5(b) WHERE mod(a,2) = 0;
> DELETE FROM test WHERE mod(a,3) = 0;
> COMMIT;
>
> The above case worked ok when remove 0004 patch, so I think it’s a problem of 0004 patch. Please have a look.

thanks for the test!
I hadn't updated the case where sending schema across was the first
change of the transaction as part of the decoding of the
truncate command. In this test case, the schema was sent across
without the stream start, hence the error on the apply worker.
I have updated with a fix. Please do a test and confirm.

regards,
Ajin Cherian
Fujitsu Australia

Attachment Content-Type Size
v94-0001-Add-support-for-prepared-transactions-to-built-i.patch application/octet-stream 143.2 KB
v94-0002-Add-prepare-API-support-for-streaming-transactio.patch application/octet-stream 54.4 KB
v94-0004-Skip-empty-streaming-in-progress-transaction-for.patch application/octet-stream 10.7 KB
v94-0003-Skip-empty-transactions-for-logical-replication.patch application/octet-stream 27.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ranier Vilela 2021-07-06 11:25:04 Re: [PATCH] Use optimized single-datum tuplesort in ExecSort
Previous Message Michael Paquier 2021-07-06 11:10:15 Re: ECPG doesn't compile CREATE AS EXECUTE properly.