postgresql/src/backend
Fujii Masao 8ee536c895 Fix WAL flush LSN used by logical walsender during shutdown
Commit 6eedb2a5fd made the logical walsender call
XLogFlush(GetXLogInsertRecPtr()) to ensure that all pending WAL is flushed,
fixing a publisher shutdown hang. However, if the last WAL record ends at
a page boundary, GetXLogInsertRecPtr() can return an LSN pointing past
the page header, which can cause XLogFlush() to report an error.

A similar issue previously existed in the GiST code. Commit b1f14c9672
introduced GetXLogInsertEndRecPtr(), which returns a safe WAL insertion end
location (returning the start of the page when the last record ends at a page
boundary), and updated the GiST code to use it with XLogFlush().

This commit fixes the issue by making the logical walsender use
XLogFlush(GetXLogInsertEndRecPtr()) when flushing pending WAL during shutdown.

Backpatch to all supported versions.

Reported-by: Andres Freund <andres@anarazel.de>
Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/vzguaguldbcyfbyuq76qj7hx5qdr5kmh67gqkncyb2yhsygrdt@dfhcpteqifux
Backpatch-through: 14
2026-03-17 08:12:32 +09:00
..
access Use GetXLogInsertEndRecPtr in gistGetFakeLSN 2026-03-13 23:26:15 +01:00
archive Fix memory leaks in error reporting with LOG level 2024-05-14 10:41:32 +02:00
backup Fix incorrect errno in OpenWalSummaryFile() 2026-02-03 11:25:16 +09:00
bootstrap Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
catalog Fix some cases of indirectly casting away const. 2026-02-25 11:19:50 -05:00
commands Don't malloc(0) in EventTriggerCollectAlterTSConfig 2026-03-04 15:04:53 +01:00
executor Tighten asserts on ParallelWorkerNumber 2026-03-14 15:30:05 +01:00
foreign Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:30 -07:00
jit Use CXXFLAGS instead of CFLAGS for linking C++ code 2026-02-26 12:06:58 -05:00
lib Accommodate very large dshash tables. 2024-12-17 15:24:45 -06:00
libpq Fix build breakage on Solaris-alikes with late-model GCC. 2025-07-23 15:44:29 -04:00
main Avoid possible crash within libsanitizer. 2025-11-05 11:09:30 -05:00
nodes Fix internal error from CollateExpr in SQL/JSON DEFAULT expressions 2025-10-09 01:07:36 -04:00
optimizer Fix computation of varnullingrels when translating appendrel Var 2026-02-20 18:01:56 +09:00
parser Fix possible incorrect column reference in ERROR message 2026-01-09 11:03:24 +13:00
partitioning Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands 2024-08-24 19:18:24 +03:00
po Translation updates 2026-02-23 13:56:36 +01:00
port Don't treat EINVAL from semget() as a hard failure. 2025-08-13 11:59:47 -04:00
postmaster Prevent restore of incremental backup from bloating VM fork. 2026-03-09 06:55:10 -04:00
regex Avoid assertion due to disconnected NFA sub-graphs in regex parsing. 2024-11-15 18:23:38 -05:00
replication Fix WAL flush LSN used by logical walsender during shutdown 2026-03-17 08:12:32 +09:00
rewrite Avoid rewriting data-modifying CTEs more than once. 2025-11-29 12:32:12 +00:00
snowball Avoid null pointer dereference crash after OOM in Snowball stemmers. 2025-02-18 21:23:59 -05:00
statistics Fix set of issues with extended statistics on expressions 2026-03-02 09:38:42 +09:00
storage Fix OldestMemberMXactId and OldestVisibleMXactId array usage 2026-03-02 19:19:29 +02:00
tcop Check for CREATE privilege on the schema in CREATE STATISTICS. 2025-11-10 09:00:00 -06:00
tsearch Fix some cases of indirectly casting away const. 2026-02-25 11:19:50 -05:00
utils Fix size underestimation of DSA pagemap for odd-sized segments 2026-03-09 13:46:33 +09:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
Makefile Fix build inconsistency due to the generation of wait-event code 2026-02-02 08:03:02 +09:00
meson.build meson: Fix import library name in Windows 2024-06-20 09:08:36 +02:00
nls.mk Add missing gettext triggers 2024-05-14 12:57:22 +02:00