XLOG_CHECKPOINT_REDO only contains the wal_level copied straight in
without an encapsulating record structure. While it works, it makes
future uses of XLOG_CHECKPOINT_REDO hard as there is nowhere to put
new data items. This fix this was inspired by the online checksums
patch which adds data to this record, but this change has value on
its own.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/
c92b5d8b-bc03-47bc-b209-
2e4a719eee32@iki.fi
}
else if (info == XLOG_CHECKPOINT_REDO)
{
- int wal_level;
+ xl_checkpoint_redo xlrec;
- memcpy(&wal_level, rec, sizeof(int));
- appendStringInfo(buf, "wal_level %s", get_wal_level_string(wal_level));
+ memcpy(&xlrec, rec, sizeof(xl_checkpoint_redo));
+ appendStringInfo(buf, "wal_level %s", get_wal_level_string(xlrec.wal_level));
}
else if (info == XLOG_LOGICAL_DECODING_STATUS_CHANGE)
{
*/
if (!shutdown)
{
+ xl_checkpoint_redo redo_rec;
+
+ WALInsertLockAcquire();
+ redo_rec.wal_level = wal_level;
+ WALInsertLockRelease();
+
/* Include WAL level in record for WAL summarizer's benefit. */
XLogBeginInsert();
- XLogRegisterData(&wal_level, sizeof(wal_level));
+ XLogRegisterData(&redo_rec, sizeof(xl_checkpoint_redo));
(void) XLogInsert(RM_XLOG_ID, XLOG_CHECKPOINT_REDO);
/*
if (info == XLOG_CHECKPOINT_REDO)
{
+ xl_checkpoint_redo xlrec;
+
/* Payload is wal_level at the time record was written. */
- memcpy(&record_wal_level, XLogRecGetData(xlogreader), sizeof(int));
+ memcpy(&xlrec, XLogRecGetData(xlogreader), sizeof(xl_checkpoint_redo));
+ record_wal_level = xlrec.wal_level;
}
else if (info == XLOG_CHECKPOINT_SHUTDOWN)
{
int wal_level;
} xl_end_of_recovery;
+/* checkpoint redo */
+typedef struct xl_checkpoint_redo
+{
+ int wal_level;
+} xl_checkpoint_redo;
+
/*
* The functions in xloginsert.c construct a chain of XLogRecData structs
* to represent the final WAL record.
xl_btree_unlink_page
xl_btree_update
xl_btree_vacuum
+xl_checkpoint_redo
xl_clog_truncate
xl_commit_ts_truncate
xl_dbase_create_file_copy_rec