agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix timeout overflow in WAIT FOR LSN
Date: Mon, 14 Sep 2026 11:50:05 +0000
Message-ID: <E1x65CH-00000000HNT-2tAs@gemulon.postgresql.org> (raw)

Fix timeout overflow in WAIT FOR LSN

Commit 447aae13b03 accepted TIMEOUT values up to INT64_MAX
milliseconds, but computing the deadline multiplies by 1000, which
caused an int64 overflow. And the command reported a timeout at once
instead of waiting.

Parse the value as an int instead, which simplifies the code and is
consistent with other timeout values such as the statement_timeout GUC.

The specified values are now rounded to the nearest millisecond, so a
positive timeout below half a millisecond becomes zero and waits
indefinitely.

Backpatch to v19, where the TIMEOUT option was introduced.

Reported-by: ChangAo Chen <cca5507@qq.com>
Author: ChangAo Chen <cca5507@qq.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/tencent_86B83240785807077600A1778566B5C12908@qq.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f260c03bccb709b61a0ddfdcc214134402150c0f

Modified Files
--------------
doc/src/sgml/ref/wait_for.sgml          | 18 +++++++++++++-----
src/backend/access/transam/xlogwait.c   |  2 +-
src/backend/commands/repack_worker.c    |  4 ++--
src/backend/commands/wait.c             | 32 +++++++-------------------------
src/include/access/xlogwait.h           |  2 +-
src/test/recovery/t/049_wait_for_lsn.pl | 14 ++++++++++++++
6 files changed, 38 insertions(+), 34 deletions(-)



view thread (2+ messages)

Message-ID: <E1x65CH-00000000HNT-2tAs@gemulon.postgresql.org>
Permalink:  ../E1x65CH-00000000HNT-2tAs@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1x65CH-00000000HNT-2tAs@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akorotkov@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix timeout overflow in WAIT FOR LSN
  In-Reply-To: <E1x65CH-00000000HNT-2tAs@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox