Skip to content

Commit 0bd624d

Browse files
committed
Distinguish XLOG_FPI records generated for hint-bit updates.
Add a new XLOG_FPI_FOR_HINT record type, and use that for full-page images generated for hint bit updates, when checksums are enabled. The new record type is replayed exactly the same as XLOG_FPI, but allows them to be tallied separately e.g. in pg_xlogdump.
1 parent e2dc3f5 commit 0bd624d

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

src/backend/access/rmgrdesc/xlogdesc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
7474

7575
appendStringInfo(buf, "%s", xlrec->rp_name);
7676
}
77-
else if (info == XLOG_FPI)
77+
else if (info == XLOG_FPI || info == XLOG_FPI_FOR_HINT)
7878
{
7979
/* no further information to print */
8080
}
@@ -170,6 +170,9 @@ xlog_identify(uint8 info)
170170
case XLOG_FPI:
171171
id = "FPI";
172172
break;
173+
case XLOG_FPI_FOR_HINT:
174+
id = "FPI_FOR_HINT";
175+
break;
173176
}
174177

175178
return id;

src/backend/access/transam/xlog.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8545,7 +8545,8 @@ xlog_redo(XLogReaderState *record)
85458545
XLogRecPtr lsn = record->EndRecPtr;
85468546

85478547
/* in XLOG rmgr, backup blocks are only used by XLOG_FPI records */
8548-
Assert(!XLogRecHasAnyBlockRefs(record) || info == XLOG_FPI);
8548+
Assert(info == XLOG_FPI || info == XLOG_FPI_FOR_HINT ||
8549+
!XLogRecHasAnyBlockRefs(record));
85498550

85508551
if (info == XLOG_NEXTOID)
85518552
{
@@ -8730,7 +8731,7 @@ xlog_redo(XLogReaderState *record)
87308731
{
87318732
/* nothing to do here */
87328733
}
8733-
else if (info == XLOG_FPI)
8734+
else if (info == XLOG_FPI || info == XLOG_FPI_FOR_HINT)
87348735
{
87358736
Buffer buffer;
87368737

@@ -8739,12 +8740,15 @@ xlog_redo(XLogReaderState *record)
87398740
* block. The block reference must include a full-page image -
87408741
* otherwise there would be no point in this record.
87418742
*
8742-
* Since the only change in these backup block are hint bits, there
8743-
* are no recovery conflicts generated.
8743+
* No recovery conflicts are generated by these generic records - if a
8744+
* resource manager needs to generate conflicts, it has to define a
8745+
* separate WAL record type and redo routine.
87448746
*
8745-
* This also means there is no corresponding API call for this, so an
8746-
* smgr implementation has no need to implement anything. Which means
8747-
* nothing is needed in md.c etc
8747+
* XLOG_FPI_FOR_HINT records are generated when a page needs to be
8748+
* WAL- logged because of a hint bit update. They are only generated
8749+
* when checksums are enabled. There is no difference in handling
8750+
* XLOG_FPI and XLOG_FPI_FOR_HINT records, they use a different info
8751+
* code just to distinguish them for statistics purposes.
87488752
*/
87498753
if (XLogReadBufferForRedo(record, 0, &buffer) != BLK_RESTORED)
87508754
elog(ERROR, "unexpected XLogReadBufferForRedo result when restoring backup block");

src/backend/access/transam/xloginsert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ XLogSaveBufferForHint(Buffer buffer, bool buffer_std)
786786
BufferGetTag(buffer, &rnode, &forkno, &blkno);
787787
XLogRegisterBlock(0, &rnode, forkno, blkno, copied_buffer, flags);
788788

789-
recptr = XLogInsert(RM_XLOG_ID, XLOG_FPI);
789+
recptr = XLogInsert(RM_XLOG_ID, XLOG_FPI_FOR_HINT);
790790
}
791791

792792
return recptr;

src/backend/replication/logical/decode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ DecodeXLogOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
170170
case XLOG_PARAMETER_CHANGE:
171171
case XLOG_RESTORE_POINT:
172172
case XLOG_FPW_CHANGE:
173+
case XLOG_FPI_FOR_HINT:
173174
case XLOG_FPI:
174175
break;
175176
default:

src/include/catalog/pg_control.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ typedef struct CheckPoint
6767
#define XLOG_RESTORE_POINT 0x70
6868
#define XLOG_FPW_CHANGE 0x80
6969
#define XLOG_END_OF_RECOVERY 0x90
70-
#define XLOG_FPI 0xA0
70+
#define XLOG_FPI_FOR_HINT 0xA0
71+
#define XLOG_FPI 0xB0
7172

7273

7374
/*

0 commit comments

Comments
 (0)