Add TAP test to check recovery when redo LSN is missing
authorMichael Paquier <[email protected]>
Tue, 16 Dec 2025 05:28:05 +0000 (14:28 +0900)
committerMichael Paquier <[email protected]>
Tue, 16 Dec 2025 05:28:05 +0000 (14:28 +0900)
commit15f68cebdcecf5a5508aaa12780526232c13c3f0
tree1b8e5cce9c608b501aeff4c7df2c4298956ebb9a
parentdc7c77f825d778cd49d35544c21e7efe1cd240af
Add TAP test to check recovery when redo LSN is missing

This commit provides test coverage for dc7c77f825d7, where the redo
record and the checkpoint record finish on different WAL segments with
the start of recovery able to detect that the redo record is missing.

This test uses a wait injection point done in the critical section of a
checkpoint, method that requires not one but actually two wait injection
points to avoid any memory allocations within the critical section of
the checkpoint:
- Checkpoint run with a background psql.
- One first wait point is run by the checkpointer before the critical
section, allocating the shared memory required by the DSM registry for
the wait machinery in the library injection_points.
- First point is woken up.
- Second wait point is loaded before the critical section, allocating
the memory to build the path to the library loaded, then run in the
critical section once the checkpoint redo record has been logged.
- WAL segment is switched while waiting on the second point.
- Checkpoint completes.
- Stop cluster with immediate mode.
- The segment that includes the redo record is removed.
- Start, recovery fails as the redo record cannot be found.

The error message introduced in dc7c77f825d7 is now reduced to a FATAL,
meaning that the information is still provided while being able to use a
test for it.  Nitin has provided a basic version of the test, that I
have enhanced to make it portable with two points.  Without
dc7c77f825d7, the cluster crashes in this test, not on a PANIC but due
to the pointer dereference at the beginning of recovery, failure
mentioned in the other commit.

Author: Nitin Jadhav <[email protected]>
Co-authored-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/CAMm1aWaaJi2w49c0RiaDBfhdCL6ztbr9m=daGqiOuVdizYWYaA@mail.gmail.com
src/backend/access/transam/xlog.c
src/backend/access/transam/xlogrecovery.c
src/test/recovery/meson.build
src/test/recovery/t/050_redo_segment_missing.pl [new file with mode: 0644]