Re: [HACKERS] logical decoding of two-phase transactions - Mailing list pgsql-hackers

From Ajin Cherian
Subject Re: [HACKERS] logical decoding of two-phase transactions
Date
Msg-id CAFPTHDZyffPtB4McWf8VU2of2C3qEKwJdzkKCm54=cUu_ZWZuw@mail.gmail.com
Whole thread Raw
In response to RE: [HACKERS] logical decoding of two-phase transactions  ("tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>)
Responses RE: [HACKERS] logical decoding of two-phase transactions
List pgsql-hackers
On Fri, Jul 2, 2021 at 8:18 PM tanghy.fnst@fujitsu.com
<tanghy.fnst@fujitsu.com> wrote:
>
> Thanks for your patch. I met an issue while using it. When a transaction contains TRUNCATE, the subscriber reported
anerror: " 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

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: ECPG doesn't compile CREATE AS EXECUTE properly.
Next
From: Ranier Vilela
Date:
Subject: Re: [PATCH] Use optimized single-datum tuplesort in ExecSort