mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
During online checkpoints, insert XLOG_CHECKPOINT_REDO at redo point.
This allows tools that read the WAL sequentially to identify (possible) redo points when they're reached, rather than only being able to detect them in retrospect when XLOG_CHECKPOINT_ONLINE is found, possibly much later in the WAL stream. There are other possible applications as well; see the discussion links below. Any redo location that precedes the checkpoint location should now point to an XLOG_CHECKPOINT_REDO record, so add a cross-check to verify this. While adjusting the code in CreateCheckPoint() for this patch, I made it call WALInsertLockAcquireExclusive a bit later than before, since there appears to be no need for it to be held while checking whether the system is idle, whether this is an end-of-recovery checkpoint, or what the current timeline is. Bump XLOG_PAGE_MAGIC. Patch by me, based in part on earlier work from Dilip Kumar. Review by Dilip Kumar, Amit Kapila, Andres Freund, and Michael Paquier. Discussion: http://postgr.es/m/CA+TgmoYy-Vc6G9QKcAKNksCa29cv__czr+N9X_QCxEfQVpp_8w@mail.gmail.com Discussion: http://postgr.es/m/20230614194717.jyuw3okxup4cvtbt%40awork3.anarazel.de Discussion: http://postgr.es/m/CA+hUKG+b2ego8=YNW2Ohe9QmSiReh1-ogrv8V_WZpJTqP3O+2w@mail.gmail.com
This commit is contained in:
@ -80,9 +80,17 @@ SELECT pg_current_wal_lsn() AS wal_lsn4 \gset
|
||||
SELECT COUNT(*) >= 1 AS ok FROM pg_get_wal_block_info(:'wal_lsn3', :'wal_lsn4')
|
||||
WHERE relfilenode = :'sample_tbl_oid' AND block_data IS NOT NULL;
|
||||
|
||||
-- Force full-page image on the next update.
|
||||
-- Force a checkpoint so that the next update will log a full-page image.
|
||||
SELECT pg_current_wal_lsn() AS wal_lsn5 \gset
|
||||
CHECKPOINT;
|
||||
|
||||
-- Verify that an XLOG_CHECKPOINT_REDO record begins at precisely the redo LSN
|
||||
-- of the checkpoint we just performed.
|
||||
SELECT redo_lsn FROM pg_control_checkpoint() \gset
|
||||
SELECT start_lsn = :'redo_lsn'::pg_lsn AS same_lsn, resource_manager,
|
||||
record_type FROM pg_get_wal_record_info(:'redo_lsn');
|
||||
|
||||
-- This update should produce a full-page image because of the checkpoint.
|
||||
UPDATE sample_tbl SET col1 = col1 + 1 WHERE col1 = 2;
|
||||
SELECT pg_current_wal_lsn() AS wal_lsn6 \gset
|
||||
-- Check if we get FPI from WAL record.
|
||||
|
Reference in New Issue
Block a user