RE: Handle infinite recursion in logical replication setup

From: "shiy(dot)fnst(at)fujitsu(dot)com" <shiy(dot)fnst(at)fujitsu(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Peter Smith <smithpb2250(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, "kuroda(dot)hayato(at)fujitsu(dot)com" <kuroda(dot)hayato(at)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RE: Handle infinite recursion in logical replication setup
Date: 2022-07-04 08:16:45
Message-ID: OSZPR01MB63109DD4B211D087258CA360FDBE9@OSZPR01MB6310.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jul 3, 2022 11:00 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
>
> Thanks for the comments, the attached v27 patch has the changes for the
> same.
>

Thanks for updating the patch.

A comment on 0003 patch:
+ /*
+ * No need to throw an error for the tables that are in ready state,
+ * as the walsender will send the changes from WAL in case of tables
+ * in ready state.
+ */
+ if (isreadytable)
+ continue;
+
...
+ ereport(ERROR,
+ errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("table: \"%s.%s\" might have replicated data in the publisher",
+ nspname, relname),
+ errdetail("CREATE/ALTER SUBSCRIPTION with origin = local and copy_data = on is not allowed when the publisher might have replicated data."),
+ errhint("Use CREATE/ALTER SUBSCRIPTION with copy_data = off/force."));
+
+ ExecClearTuple(slot);

I think we should call ExecClearTuple() before getting next tuple, so it should
be called if the table is in ready state. How about modifying it to:
if (!isreadytable)
ereport(ERROR,
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("table: \"%s.%s\" might have replicated data in the publisher",
nspname, relname),
errdetail("CREATE/ALTER SUBSCRIPTION with origin = local and copy_data = on is not allowed when the publisher might have replicated data."),
errhint("Use CREATE/ALTER SUBSCRIPTION with copy_data = off/force."));

ExecClearTuple(slot);

Regards,
Shi yu

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2022-07-04 08:26:19 Re: Allowing REINDEX to have an optional name
Previous Message Peter Smith 2022-07-04 07:37:09 Re-order "disable_on_error" in tab-complete COMPLETE_WITH