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=dagqiouvdizyw...@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/15f68cebdcecf5a5508aaa12780526232c13c3f0

Modified Files
--------------
src/backend/access/transam/xlog.c               |   6 ++
src/backend/access/transam/xlogrecovery.c       |   2 +-
src/test/recovery/meson.build                   |   1 +
src/test/recovery/t/050_redo_segment_missing.pl | 117 ++++++++++++++++++++++++
4 files changed, 125 insertions(+), 1 deletion(-)

Reply via email to