From 21242ba0bd467f151fa0cdf07c392f953b37c70b Mon Sep 17 00:00:00 2001 From: Goutham Reddy Aenugu Date: Sat, 21 Nov 2026 03:37:48 -0800 Subject: [PATCH v1 1/3] Clarify what a standby promotion timeout means A promotion can finish after the client stops waiting. Treating a timeout or a read-only connection as proof that the standby will stay in recovery can lead to two writable servers during failover. Explain the timeout in the pg_promote() and pg_ctl documentation, and describe when a restart stops returning the server to standby mode. --- doc/src/sgml/func/func-admin.sgml | 16 ++++++++++++---- doc/src/sgml/high-availability.sgml | 12 ++++++++++++ doc/src/sgml/ref/pg_ctl-ref.sgml | 5 ++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/doc/src/sgml/func/func-admin.sgml b/doc/src/sgml/func/func-admin.sgml index ed87226..ad52803 100644 --- a/doc/src/sgml/func/func-admin.sgml +++ b/doc/src/sgml/func/func-admin.sgml @@ -811,15 +811,23 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset Promotes a standby server to primary status. With wait set to true (the - default), the function waits until promotion is completed - or wait_seconds seconds have passed, and - returns true if promotion is successful - and false otherwise. + default), the function waits for promotion to complete and returns + true if it observes completion within + wait_seconds seconds. If the wait times out, + the function returns false and the promotion can + still complete in the background. If wait is set to false, the function returns true immediately after sending a SIGUSR1 signal to the postmaster to trigger promotion. + + Use pg_is_in_recovery() to check whether recovery + has ended, or the + pg_stat_recovery view to check whether + the startup process has accepted the promotion request. See + for details. + This function is restricted to superusers by default, but other users can be granted EXECUTE to run the function. diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml index 6e42e0e..840c151 100644 --- a/doc/src/sgml/high-availability.sgml +++ b/doc/src/sgml/high-availability.sgml @@ -1572,6 +1572,18 @@ postgres=# WAIT FOR LSN '0/306EE20'; you don't need to promote. + + A timeout while waiting for promotion only ends the caller's wait. The + standby can still become a primary. During promotion, the server selects + a new timeline and durably removes standby.signal. + After this removal, a restart will no longer bring the server back up as + a standby unless standby mode is configured again. Until recovery + finishes, pg_is_in_recovery() still returns + true, and hot standby sessions still run read-only + transactions. These observations alone do not establish that it is safe + to make another server writable. + + On a standby with set to diff --git a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml index b762b00..4dbf497 100644 --- a/doc/src/sgml/ref/pg_ctl-ref.sgml +++ b/doc/src/sgml/ref/pg_ctl-ref.sgml @@ -230,7 +230,10 @@ PostgreSQL documentation mode commands the standby server that is running in the specified data directory to end standby mode - and begin read-write operations. + and begin read-write operations. A timeout while waiting for promotion + ends the pg_ctl wait, and the server can still + complete promotion in the background. See + for details. -- 2.56.1