pgsql: Disallow negative values for max_retention_duration.

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Disallow negative values for max_retention_duration.
Date: 2026-06-11 05:54:20
Message-ID: E1wXYMu-001xoY-0C@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Disallow negative values for max_retention_duration.

The subscription option max_retention_duration accepts an integer value
representing a timeout in milliseconds, where zero means unlimited
retention (no timeout). Negative values have no useful meaning, but were
silently accepted and stored in the subscription catalog.

A negative value causes should_stop_conflict_info_retention() to always
return true, because TimestampDifferenceExceeds() treats a negative
threshold as already exceeded. This stops dead tuple retention
immediately rather than honoring the configured timeout.

Fix by rejecting negative values for max_retention_duration during CREATE
SUBSCRIPTION and ALTER SUBSCRIPTION.

Author: Chao Li <lic(at)highgo(dot)com>
Reviewed-by: Hayato Kuroda <kuroda(dot)hayato(at)fujitsu(dot)com>
Reviewed-by: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Discussion: https://postgr.es/m/9232401A-DEEE-49E1-9D11-D14A776DB82B@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/987440b33a511482232c59a190cc16ae4feff9aa

Modified Files
--------------
src/backend/commands/subscriptioncmds.c | 5 +++++
src/test/regress/expected/subscription.out | 6 ++++++
src/test/regress/sql/subscription.sql | 6 ++++++
3 files changed, 17 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-06-11 08:30:01 pgsql: Fix race with timeline selection in logical decoding during prom
Previous Message Michael Paquier 2026-06-11 05:44:54 pgsql: Backport GetWALInsertionTimeLineIfSet()