Re: Avoid retaining conflict-related data when no tables are subscribed

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>
Subject: Re: Avoid retaining conflict-related data when no tables are subscribed
Date: 2025-08-28 05:13:23
Message-ID: CAFiTN-uSQZFNRO1z2dymv_UwgzwnsmAAnqfma2nnHCYqy7MgJg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 28, 2025 at 7:54 AM Zhijie Hou (Fujitsu)
<houzj(dot)fnst(at)fujitsu(dot)com> wrote:
>
> Hi,
>
> My colleague Nisha reported an issue to me off-list: dead tuples can't
> be removed when retain_dead_tuples is enabled for a subscription with no tables.
>
> This appears to stem from the inability to advance the non-removable transaction
> ID when AllTablesyncsReady() returns false. Since this function returns false
> when no tables are present, which leads to unnecessary data retention until a
> table is added to the subscription.
>
> Since dead tuples don't need to be retained when no tables are subscribed, here
> is a patch to fix it, modifying AllTablesyncsReady() to allows no tables to be
> treated as a ready state when explicitly requested.

+ /* If there are no tables, decide readiness based on the parameter */
+ if (!has_subrels)
+ return ready_if_no_tables;
+
/*
* Return false when there are no tables in subscription or not all tables
* are in ready state; true otherwise.
*/
- return has_subrels && (table_states_not_ready == NIL);
+ return table_states_not_ready == NIL;

The first part of the comment "Return false when there are no tables
in subscription" is outdated now with your fix. Otherwise it looks
fine.

--
Regards,
Dilip Kumar
Google

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2025-08-28 05:19:11 Re: Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy
Previous Message shveta malik 2025-08-28 05:06:07 Re: Avoid retaining conflict-related data when no tables are subscribed