postgresql/src/backend
Michael Paquier a8ee70bd5e Fix second race with timeline selection during promotion
read_local_xlog_page_guts has the same race as logical_read_xlog_page:
RecoveryInProgress() can return true during promotion, impacting the
availability of the operations doing WAL page reads with this callback.

This problem is similar to eb4e7224a1 that has addressed the issue for
logical replication, impacting more areas of the code where this WAL
page callback can be used (same narrow window during promotion, same
availability issue):
- pg_walinspect.
- Slot advance (SQL function).
- Slot creation.

Repack workers (v19~) and 2PC files (since forever) can also use this
callback, but they are irrelevant as far as I know.  A test is added
with the SQL lookup functions.  This part relies on injection points,
and is backpatched down to v18, like the test added for eb4e7224a1.

This issue could probably be fixed as well in v14 and v15 for
pg_walinspect.  However, I also feel that there is a conservative
argument about consistency here due to the support of logical decoding
on standbys, so let's limit ourselves to v16 for now.  pg_walinspect is
used less in the field compared to the two other operations, making
addressing this problem less attractive in these two older branches.

Reported-by: Xuneng Zhou <xunengzhou@gmail.com>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Discussion: https://postgr.es/m/7daef094-abf3-4672-bc23-3df4763b16a3%40gmail.com
Backpatch-through: 16
2026-06-12 11:44:11 +09:00
..
access Fix second race with timeline selection during promotion 2026-06-12 11:44:11 +09:00
archive Don't include wait_event.h in pgstat.h 2026-03-06 16:24:58 +01:00
backup Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
bootstrap Rework signal handler infrastructure to pass sender info as argument. 2026-04-15 07:30:34 -04:00
catalog Fix translatable string construction 2026-06-11 18:29:36 +02:00
commands Fix translatable string construction 2026-06-11 18:29:36 +02:00
executor Revert "Enable fast default for domains with non-volatile constraints" 2026-06-08 14:20:39 -04:00
foreign Remove bits* typedefs. 2026-03-30 16:12:08 -05:00
jit Fix another case of indirectly casting away const. 2026-06-04 11:37:55 -04:00
lib Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
libpq Fix md5_password_warnings for role and database settings 2026-06-12 08:32:39 +09:00
main Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodes IS JSON/JSON(): Protect against expressions uncoercible to text 2026-06-11 16:17:58 +02:00
optimizer Fix missed checks for hashability of container-type equality. 2026-06-08 11:48:16 -04:00
parser IS JSON/JSON(): Protect against expressions uncoercible to text 2026-06-11 16:17:58 +02:00
partitioning Reject degenerate SPLIT PARTITION with DEFAULT partition 2026-05-25 11:57:42 +03:00
po Translation updates 2026-06-01 12:13:54 +02:00
port Use "grep -E" not "egrep". 2026-05-13 12:07:19 -04:00
postmaster Fix syslogger NULL-pointer-dereference in EXEC_BACKEND 2026-06-08 19:49:54 +02:00
regex Harden our regex engine against integer overflow in size calculations. 2026-05-11 05:13:46 -07:00
replication Fix translatable string construction 2026-06-11 18:29:36 +02:00
rewrite Fix LATERAL references in GRAPH_TABLE with multi-label pattern 2026-06-05 09:27:51 +02:00
snowball Fix meson build of snowball code. 2026-01-05 16:51:36 -05:00
statistics Adjust some error hints 2026-05-26 08:13:22 +09:00
storage Fix MarkBufferDirtyHint() to not call GetBufferDescriptor() for local buffers 2026-06-10 13:49:26 +09:00
tcop Simplify signature of ProcessStartupPacket() 2026-05-17 07:44:17 +09:00
tsearch dict_synonym.c: remove incorrect outlen. 2026-06-08 11:47:53 -07:00
utils Confine RI fast-path batching to the top transaction level 2026-06-12 11:30:38 +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 ssl: Serverside SNI support for libpq 2026-03-18 12:37:11 +01:00
meson.build Add CONCURRENTLY option to REPACK 2026-04-06 21:55:08 +02:00
nls.mk Create a separate file listing backend types 2025-09-26 15:21:49 +02:00