| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
| Cc: | PostgreSQL-development <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com> |
| Subject: | Re: Reject negative max_retention_duration values |
| Date: | 2026-06-09 23:22:42 |
| Message-ID: | 65192DF4-1D6D-4743-8467-66115C494089@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Jun 9, 2026, at 22:44, Hayato Kuroda (Fujitsu) <kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>
> Dear Chao,
>
> +1 the idea to reject the negative value.
>
> ```
> @@ -4796,7 +4796,7 @@ should_stop_conflict_info_retention(RetainDeadTuplesData *rdt_data)
> Assert(rdt_data->phase == RDT_WAIT_FOR_PUBLISHER_STATUS ||
> rdt_data->phase == RDT_WAIT_FOR_LOCAL_FLUSH);
>
> - if (!MySubscription->maxretention)
> + if (MySubscription->maxretention <= 0)
> return false;
> ```
>
> IIUC, the negative value can be rejected at CREATE/ALTER SUBSCRIPTION phase, right?
> Why do we have to update even here? For the clarification purpose?
>
Thanks for your review.
Yes, this patch rejects negative values at CREATE/ALTER SUBSCRIPTION time, so in theory the if (MySubscription->maxretention <= 0) change is not strictly necessary. I made that change for a few reasons (from strong do weak):
* The new check is equivalent to if (!(MySubscription->maxretention > 0)), meaning MySubscription->maxretention is not meaningful for this function unless it is positive. So semantically, I think it is correct, or at least it does not hurt anything.
* The new check makes the purpose more explicit in this function: only positive values are meaningful here.
* It also keeps the worker logic self-contained: this function only performs timeout checks when max_retention_duration is positive, instead of relying entirely on option parsing to ensure that.
* Since v19beta1 has been released, there is a very small possibility that some databases, most likely test deployments, may already have negative max_retention_duration values, so this also acts as defensive coding. I understand beta1 can never be a production deployment, so this is just a weak reason.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-06-10 00:21:25 | Re: pg_plan_advice |
| Previous Message | Zsolt Parragi | 2026-06-09 22:06:38 | Re: Add pg_get_publication_ddl function |