pgsql: Improve timeout handling of pg_promote() - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Improve timeout handling of pg_promote()
Date
Msg-id E1w5Zie-001T6v-2k@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Improve timeout handling of pg_promote()

Previously, pg_promote() looped a fixed number of times, calculated from
the specified timeout, and waited 100ms on a latch, once per iteration,
for the promotion of a standby to complete.  However, unrelated signals
to the backend could set the latch and wake up the backend early,
resulting in a faster consumption of the loops and an execution time of
the function that does not match with the timeout input given in input.
This could be confusing for the function caller, especially if some
backend-side timeout is aggressive, because the function would return
much earlier than expected and report that the promote request has not
completed within the time requested.

This commit refines the logic to track the time actually elapsed, by
looping until the requested duration has truly passed.  The code
calculates the end time we expect, then uses it when looping.

Author: Robert Pang <robertpang@google.com>
Reviewed-by: Tiancheng Ge <getiancheng_2012@163.com>
Discussion: https://postgr.es/m/CAJhEC07OK8J7tLUbyiccnuOXRE7UKxBNqD2-pLfeFXa=tBoWtw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4287c50fc21e6d1c7798955020f8438ae2327472

Modified Files
--------------
src/backend/access/transam/xlogfuncs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Remove a low-value, high-risk optimization in pg_waldump.
Next
From: Masahiko Sawada
Date:
Subject: pgsql: Fix UUID sortability tests in base32hex encoding.