From: | "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com> |
---|---|
To: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
Cc: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com> |
Subject: | RE: Conflict detection for update_deleted in logical replication |
Date: | 2025-07-20 03:05:37 |
Message-ID: | OS0PR01MB57169451CCE0AFF66348B3399452A@OS0PR01MB5716.jpnprd01.prod.outlook.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Saturday, July 19, 2025 5:31 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> Here are some review comments and questions:
Thanks for the comments!
>
> + /*
> + * Do not allow users to acquire the reserved slot. This scenario may
> + * occur if the launcher that owns the slot has terminated unexpectedly
> + * due to an error, and a backend process attempts to reuse the slot.
> + */
> + if (!IsLogicalLauncher() && IsReservedSlotName(name))
> + ereport(ERROR,
> + errcode(ERRCODE_UNDEFINED_OBJECT),
> + errmsg("cannot acquire replication slot \"%s\"", name),
> + errdetail("The slot is reserved for conflict detection
> and can only be acquired by logical replication launcher."));
>
> I think it might be better to rename IsReservedSlotName() to be more specific to
> the conflict detection because we might want to add more reserved slot names
> in the future that would not necessarily be acquired only by the launcher
> process.
Agreed. I have renamed it to IsSlotForConflictCheck.
>
> ---
> Regarding the option name we've discussed:
>
> > > The new parameter name "retain_conflict_info" sounds to me like we
> > > keep the conflict information somewhere that has expired at some
> > > time such as how many times insert_exists or update_origin_differs
> > > happened. How about choosing a name that indicates retain dead
> > > tuples more explicitly for example retain_dead_tuples?
> >
> > We considered the name you suggested, but we wanted to convey that
> > this option not only retains dead tuples but also preserves commit
> > timestamps and origin data for conflict detection, hence we opted for
> > a more general name. Do you have better suggestions?
>
> I think the commit timestamp and origin data would be retained as a result of
> retaining dead tuples. While such a general name could convey more than
> retaining dead tuples, I'm concerned that it could be ambiguous what exactly to
> retain by the subscription. How about the following names or something along
> those lines?
>
> - retain_dead_tuples_for_conflict
> - delay_vacuum_for_conflict
> - keep_dead_tuples_for_conflict
OK, I use the shorter version retain_conflict_info as mentioned by Amit[1].
>
> ---
> +check_pub_conflict_info_retention(WalReceiverConn *wrconn, bool
> retain_conflict_info)
> +{
> + WalRcvExecResult *res;
> + Oid RecoveryRow[1] = {BOOLOID};
> + TupleTableSlot *slot;
> + bool isnull;
> + bool remote_in_recovery;
> +
> + if (!retain_conflict_info)
> + return;
>
> It seems that retain_conflict_info is used only for this check to quick exit from
> this function. How about calling this function only when the caller knows
> retain_conflict_info is true instead of adding it as a function argument?
Changed as suggested.
>
> ---
> +void
> +CheckSubConflictInfoRetention(bool retain_conflict_info, bool check_guc,
> + bool sub_disabled, int
> +elevel_for_sub_disabled)
>
> This function seems not to be specific to the apply workers but to
> subscriptions in general. Is there any reason why we define this function in
> worker.c?
I do not have special reasons, so I moved it to subscriptioncmd.c
where most checks are performed.
>
> ---
> + if (check_guc && wal_level < WAL_LEVEL_REPLICA)
> + ereport(ERROR,
> +
> errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> + errmsg("\"wal_level\" is insufficient to create the
> replication slot required by retain_conflict_info"),
> + errhint("\"wal_level\" must be set to \"replica\" or
> \"logical\" at server start."));
> +
>
> Why does (retain_conflict_info == false && wal_level == minimal) not work?
I think it works because the check is skipped when rci is false. BTW, to be consistent with
check_pub_conflict_info_retention, I moved the retain_conflict_info check outside of this
function.
Best Regards,
Hou zj
Attachment | Content-Type | Size |
---|---|---|
v50-0001-Preserve-conflict-relevant-data-during-logical-r.patch | application/octet-stream | 186.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2025-07-20 03:19:32 | Re: Documenting inlining SQL functions |
Previous Message | Tender Wang | 2025-07-20 00:05:58 | Re: MergeJoin beats HashJoin in the case of multiple hash clauses |