pgsql: Extend xlogwait infrastructure with write and flush wait types

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Extend xlogwait infrastructure with write and flush wait types
Date: 2026-01-05 17:56:31
Message-ID: E1vcoog-004gOG-29@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Extend xlogwait infrastructure with write and flush wait types

Add support for waiting on WAL write and flush LSNs in addition to the
existing replay LSN wait type. This provides the foundation for
extending the WAIT FOR command with MODE parameter.

Key changes are following.
- Add WAIT_LSN_TYPE_STANDBY_WRITE and WAIT_LSN_TYPE_STANDBY_FLUSH to
WaitLSNType.
- Add GetCurrentLSNForWaitType() to retrieve the current LSN for each wait
type.
- Add new wait events WAIT_EVENT_WAIT_FOR_WAL_WRITE and
WAIT_EVENT_WAIT_FOR_WAL_FLUSH for pg_stat_activity visibility.
- Update WaitForLSN() to use GetCurrentLSNForWaitType() internally.

Discussion: https://postgr.es/m/CABPTF7UiArgW-sXj9CNwRzUhYOQrevLzkYcgBydmX5oDes1sjg%40mail.gmail.com
Author: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Reviewed-by: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Alvaro Herrera <alvherre(at)kurilemu(dot)de>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7a39f43d885b44a78f366aa50535944c4e38bdbb

Modified Files
--------------
src/backend/access/transam/xlog.c | 2 +-
src/backend/access/transam/xlogrecovery.c | 4 +-
src/backend/access/transam/xlogwait.c | 96 ++++++++++++++++++++-----
src/backend/commands/wait.c | 2 +-
src/backend/utils/activity/wait_event_names.txt | 3 +-
src/include/access/xlogwait.h | 14 ++--
6 files changed, 93 insertions(+), 28 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-01-05 18:16:47 pgsql: Fix typo in parallel.c.
Previous Message Robert Haas 2026-01-05 17:38:58 pgsql: Remove redundant SET enable_partitionwise_join = on.