Re: New WAL record to detect the checkpoint redo location

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: New WAL record to detect the checkpoint redo location
Date: 2023-08-27 23:44:22
Message-ID: ZOvf1tu6rfL/B2PW@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Aug 25, 2023 at 11:08:25AM +0530, Dilip Kumar wrote:
> Here is the updated version of the patch.

The concept of the patch looks sound to me. I have a few comments.

+ * This special record, however, is not required when we doing a shutdown
+ * checkpoint, as there will be no concurrent wal insertions during that
+ * time. So, the shutdown checkpoint LSN will be the same as
+ * checkpoint-redo LSN.

This is missing "are", as in "when we are doing a shutdown
checkpoint".

- freespace = INSERT_FREESPACE(curInsert);
- if (freespace == 0)

The variable "freespace" can be moved within the if block introduced
by this patch when calculating the REDO location for the shutdown
case. And you can do the same with curInsert?

- * Compute new REDO record ptr = location of next XLOG record.
- *
- * NB: this is NOT necessarily where the checkpoint record itself will be,
- * since other backends may insert more XLOG records while we're off doing
- * the buffer flush work. Those XLOG records are logically after the
- * checkpoint, even though physically before it. Got that?
+ * In case of shutdown checkpoint, compute new REDO record
+ * ptr = location of next XLOG record.

It seems to me that keeping around this comment is important,
particularly for the case where we have a shutdown checkpoint and we
expect nothing to run, no?

How about adding a test in pg_walinspect? There is an online
checkpoint running there, so you could just add something like that
to check that the REDO record is at the expected LSN stored in the
control file:
+-- Check presence of REDO record.
+SELECT redo_lsn FROM pg_control_checkpoint() \gset
+SELECT start_lsn = :'redo_lsn'::pg_lsn AS same_lsn, record_type
+ FROM pg_get_wal_record_info(:'redo_lsn');
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2023-08-28 00:04:45 Re: subscription/015_stream sometimes breaks
Previous Message Thomas Munro 2023-08-27 23:24:39 Re: CI speed improvements for FreeBSD