Provide a way to attach data to WAL record conditionally, so that it is
included only if this turns out to the be first modification to a given
block after a checkpoint.
This will be used to record undo log meta-data, to avoid a data
synchronization problem with online checkpoints.
Author: Thomas Munro
Reviewed-by:
Discussion:
needs_data = false;
else if ((regbuf->flags & REGBUF_KEEP_DATA) != 0)
needs_data = true;
+ else if ((regbuf->flags & REGBUF_KEEP_DATA_AFTER_CP) != 0)
+ {
+ XLogRecPtr page_lsn = PageGetLSN(regbuf->page);
+
+ needs_data = (page_lsn <= RedoRecPtr);
+ if (!needs_data)
+ {
+ /*
+ * XLogInsertRecord() will detect if our view of the latest
+ * checkpoint's RedoRecPtr is out of date.
+ */
+ if (*fpw_lsn == InvalidXLogRecPtr || page_lsn < *fpw_lsn)
+ *fpw_lsn = page_lsn;
+ }
+ }
else
needs_data = !needs_backup;
* will be skipped) */
#define REGBUF_KEEP_DATA 0x10 /* include data even if a full-page image
* is taken */
+#define REGBUF_KEEP_DATA_AFTER_CP 0x20 /* include data on the first
+ * modification after a checkpoint */
/* prototypes for public functions in xloginsert.c: */
extern void XLogBeginInsert(void);