On Tue, Aug 15, 2023 at 02:23:43PM +0530, Dilip Kumar wrote: > Yeah, good idea, actually we can do this insert outside of the > exclusive insert lock and set the LSN of this insert as the > checkpoint. redo location. So now we do not need to compute the > checkpoint. redo based on the current insertion point we can directly > use the LSN of this record. I have modified this and I have also > moved some other code that is not required to be inside the WAL > insertion lock.
Looking at this patch, I am bit surprised to see that the redo point maps with the end location of the CHECKPOINT_REDO record as it is the LSN returned by XLogInsert(), not its start LSN. For example after a checkpoint: =# CREATE EXTENSION pg_walinspect; CREATE EXTENSION; =# SELECT redo_lsn, checkpoint_lsn from pg_control_checkpoint(); redo_lsn | checkpoint_lsn -----------+---------------- 0/19129D0 | 0/1912A08 (1 row) =# SELECT start_lsn, prev_lsn, end_lsn, record_type from pg_get_wal_record_info('0/19129D0'); start_lsn | prev_lsn | end_lsn | record_type -----------+-----------+-----------+--------------- 0/19129D0 | 0/19129B0 | 0/1912A08 | RUNNING_XACTS (1 row) In this case it matches with the previous record: =# SELECT start_lsn, prev_lsn, end_lsn, record_type from pg_get_wal_record_info('0/19129B0'); start_lsn | prev_lsn | end_lsn | record_type -----------+-----------+-----------+----------------- 0/19129B0 | 0/1912968 | 0/19129D0 | CHECKPOINT_REDO (1 row) This could be used to cross-check that the first record replayed is of the correct type. The commit message of this patch tells that "the checkpoint-redo location is set at LSN of this record", which implies the start LSN of the record tracked as the redo LSN, not the end of it? What's the intention here? -- Michael
signature.asc
Description: PGP signature