]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Remove redundant WAIT FOR LSN caller-side pre-checks
authorAlexander Korotkov <akorotkov@postgresql.org>
Sun, 3 May 2026 13:17:32 +0000 (16:17 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Sun, 3 May 2026 13:22:02 +0000 (16:22 +0300)
commitdf9f938ca2ec30e1018a76d80ccc77c7073d7acf
tree8c24bf6c0eb748feeff18795f0017d4490f69abf
parenta80a593ab63696a0ad0e5c10b9e1b99aaa98032e
Remove redundant WAIT FOR LSN caller-side pre-checks

All five wakeup call sites duplicate WaitLSNWakeup()'s internal
fast-path minWaitedLSN check and add an unnecessary NULL check
on waitLSNState.

Remove the inline pre-checks and call WaitLSNWakeup() directly.
The fast-path check inside WaitLSNWakeup() already returns early
when no waiter's target has been reached, so there is no
performance difference.

The waitLSNState NULL checks are also unnecessary: shared memory
is fully initialized before any backend or auxiliary process
starts, so waitLSNState is always non-NULL at these call sites.

Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/jzq5shdewncpxc35r3s2mcfsmo4bjovkza5mnqf5bdfumhfi3g%40bglckf7dxmw5
Author: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
src/backend/access/transam/xlog.c
src/backend/access/transam/xlogrecovery.c
src/backend/replication/walreceiver.c