From b313920e22f0909e337e4d169bddde9859a65f94 Mon Sep 17 00:00:00 2001 From: Alexander Korotkov Date: Wed, 16 Sep 2026 15:39:16 +0300 Subject: [PATCH v4] doc: Explain when to use the WAIT NO_THROW option The description of NO_THROW covered what the option does but not when an application would want it. Explain that it suits callers that treat timeout or not in recovery as expected results to be handled as part of ordinary control flow, note the obligation to check the returned status, and give the reason to omit the option. Be precise about the option's scope: it changes only how those two wait outcomes are reported. Soften the description's claim that the command "returns a status string instead of throwing errors" accordingly, and say that invalid input still raises an error, as does any condition checked before the wait begins. Name two of those conditions as examples rather than listing them, since the set grows. Author: Rithvika Devisetti Reported-by: Peter Eisentraut Reviewed-by: Kiran Kaki Reviewed-by: Xuneng Zhou Reviewed-by: Satyanarayana Narlapuram Reviewed-by: Alexander Korotkov Discussion: https://postgr.es/m/14415b05-16d0-446f-ba7d-c891db8b3406%40eisentraut.org Backpatch-through: 19 --- doc/src/sgml/ref/wait.sgml | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/doc/src/sgml/ref/wait.sgml b/doc/src/sgml/ref/wait.sgml index 9056eb6726b..68ca7101eba 100644 --- a/doc/src/sgml/ref/wait.sgml +++ b/doc/src/sgml/ref/wait.sgml @@ -54,8 +54,8 @@ WAIT FOR LSN 'lsn' (standby_replay, standby_write, standby_flush), an error is also emitted if the server is promoted before the lsn is reached. - If NO_THROW is specified, the command returns - a status string instead of throwing errors. + If NO_THROW is specified, the command reports + these outcomes as a status string instead of raising an error. @@ -172,6 +172,39 @@ WAIT FOR LSN 'lsn' running on the primary. In this case the result status can be obtained from the return value. + + + Use this option when timeout or + not in recovery is an expected result that the + application intends to handle, for example by retrying the wait, + reporting replication delay, or choosing another server for a + subsequent operation. The command then returns the result as a + status, which the application must check before assuming that the + target LSN was reached. Omit the option when + the application must not proceed unless the target + LSN is reached, so that an unsuccessful wait + stops normal execution with an error. + + + + Returning a status also leaves an explicit transaction usable; + without this option, the corresponding error requires rolling back + the transaction, or rolling back to a savepoint, before further + commands can be issued. + + + + This option changes only how timeout and + not in recovery are reported. Other errors are + still raised. That covers invalid input, such as a malformed + LSN or an unrecognized option value, and every + condition that is checked before the wait begins, such as + requesting primary_flush during recovery or + holding a lock while waiting for a standby + LSN. The option also does not limit the + duration of the wait; specify TIMEOUT for that + purpose. + -- 2.55.0