Re: BUG #18203: Logical Replication initial sync failure

From: vignesh C <vignesh21(at)gmail(dot)com>
To: zzzzz(dot)graf(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18203: Logical Replication initial sync failure
Date: 2023-11-20 09:23:16
Message-ID: CALDaNm1JKqMXWjDVUnzJS4DOb7YPLqrsjDj4oQiqAakM0FEvBA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sat, 18 Nov 2023 at 18:10, PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
>
> The following bug has been logged on the website:
>
> Bug reference: 18203
> Logged by: Justin G
> Email address: zzzzz(dot)graf(at)gmail(dot)com
> PostgreSQL version: 15.2
> Operating system: Ubuntu 20
> Description:
>
> We’ve found an edge case that breaks logical replication.
>
> Procedure:
>
> alter system set wal_level to 'logical' ;
>
> create database source; --pg 11
> create database destin; --pg 15
>
> create table no_col(); -- pg 11
>
> insert into no_col default values;
> insert into no_col default values;
> insert into no_col default values;
> insert into no_col default values;
> insert into no_col default values;
>
> CREATE PUBLICATION no_col_pub for table no_col;
>
> create table no_col(); --pg 15
>
> CREATE SUBSCRIPTION no_col_sub --pg15
> CONNECTION
> 'host=<hostname/ip>
> port=5432
> user=<set username>
> dbname=source
> password=<set the password>'
> PUBLICATION no_col_pub
> WITH (
> CREATE_SLOT = TRUE,
> ENABLED = TRUE,
> COPY_DATA = TRUE
> );
>
>
> We now have a table with 5 null rows. This is a valid table, pg_dump will
> dump it and restore it. count(*) will return 5.
>
> The dump file produced by pg_dump version 15 generates this SQL
> COPY public.no_col FROM stdin;
>
> However, the copy command from PG 15 using logical replication includes (),
> which normally has a list of columns between the parentheses.
>
> COPY public.no_col () TO STDOUT
>
> Logical replication worker returns with the following error:
> 2023-11-17 20:40:16.141 UTC [151084] ERROR: could not start initial
> contents copy for table "public.no_col": ERROR: syntax error at or near
> ")"
> LINE 1: COPY public.no_col () TO STDOUT

Thanks for reporting this issue, I was able to reproduce the issue.
This issue is happening because we are trying to specify the column
list while the table sync worker is copying data for the table.
I felt we should not specify the column list when the table has no columns.
Attached patch has the changes to handle the same.

Regards,
Vignesh

Attachment Content-Type Size
v1-0001-Specify-parenthesis-for-tablesync-worker-copy-com.patch text/x-patch 1.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Laurenz Albe 2023-11-20 09:54:45 Re: BUG #18196: Databases Created in Turkish Language Will Not Run on the Latest Version of Windows
Previous Message Richard Guo 2023-11-20 08:49:13 Re: BUG #18187: Unexpected error: "variable not found in subplan target lists" triggered by JOIN