Skip to content

Commit f094f23

Browse files
committed
review comments
1 parent bfd5776 commit f094f23

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

src/backend/access/transam/xlog.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,10 @@ XLogInsertRecord(XLogRecData *rdata,
838838
* but not force a recomputation. (If doPageWrites was just turned off,
839839
* we could recompute the record without full pages, but we choose not to
840840
* bother.)
841+
*
842+
* However, if suppress_fpi is true, we skip the recomputation check
843+
* since we're deliberately suppressing full page images for this
844+
* record via the FPI control hook.
841845
*/
842846
if (RedoRecPtr != Insert->RedoRecPtr)
843847
{
@@ -848,8 +852,8 @@ XLogInsertRecord(XLogRecData *rdata,
848852

849853
if (doPageWrites &&
850854
(!prevDoPageWrites ||
851-
(!force_disable_full_page_write &&
852-
fpw_lsn != InvalidXLogRecPtr && fpw_lsn <= RedoRecPtr)))
855+
(!suppress_fpi &&
856+
fpw_lsn != InvalidXLogRecPtr && fpw_lsn <= RedoRecPtr)))
853857
{
854858
/*
855859
* Oops, some buffer now needs to be backed up that the caller didn't

src/backend/access/transam/xloginsert.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ int max_replication_apply_lag;
9494
int max_replication_flush_lag;
9595
int max_replication_write_lag;
9696

97-
/* NEON: Hook to control Full Page Image (FPI) writes */
98-
xlog_fpi_control_hook_type xlog_fpi_control_hook = NULL;
97+
/* NEON: Hook to determine if FPI should be suppressed for a WAL record */
98+
xlog_should_suppress_fpi_hook_type xlog_should_suppress_fpi_hook = NULL;
9999

100-
/* NEON: Global flag to force disable FPI for current WAL record */
101-
bool force_disable_full_page_write = false;
100+
/* NEON: Global flag to suppress FPI for current WAL record */
101+
bool suppress_fpi = false;
102102

103103
static registered_buffer *registered_buffers;
104104
static int max_registered_buffers; /* allocated size */
@@ -523,14 +523,14 @@ XLogInsert(RmgrId rmid, uint8 info)
523523
GetFullPageWriteInfo(&RedoRecPtr, &doPageWrites);
524524

525525
/*
526-
* NEON: Check if we should force disable FPI for this WAL record.
526+
* NEON: Check if we should suppress FPI for this WAL record.
527527
*/
528-
force_disable_full_page_write = false;
529-
if (xlog_fpi_control_hook != NULL) {
530-
force_disable_full_page_write = xlog_fpi_control_hook(rmid);
531-
elog(DEBUG1, "FPI control hook called: rmid=%u, force_disable=%d, doPageWrites=%d",
532-
rmid, force_disable_full_page_write, doPageWrites);
533-
}
528+
suppress_fpi = false;
529+
if (xlog_should_suppress_fpi_hook != NULL) {
530+
suppress_fpi = xlog_should_suppress_fpi_hook();
531+
elog(DEBUG1, "FPI suppress hook called: suppress_fpi=%d, doPageWrites=%d",
532+
suppress_fpi, doPageWrites);
533+
}
534534

535535
rdt = XLogRecordAssemble(rmid, info, RedoRecPtr, doPageWrites,
536536
&fpw_lsn, &num_fpi, &topxid_included);
@@ -632,7 +632,7 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
632632
*/
633633
XLogRecPtr page_lsn = PageGetLSN(regbuf->page);
634634

635-
if (force_disable_full_page_write)
635+
if (suppress_fpi)
636636
needs_backup = false;
637637
else
638638
needs_backup = (page_lsn <= RedoRecPtr);

src/include/access/xloginsert.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,15 @@ extern int max_replication_apply_lag;
4242
extern int max_replication_flush_lag;
4343
extern int max_replication_write_lag;
4444

45-
/* NEON: Hook to control Full Page Image (FPI) writes
46-
* Returns true to DISABLE FPI, false to keep FPI enabled
47-
* Parameters:
48-
* rmid - Resource manager ID (e.g., RM_HEAP_ID, RM_BTREE_ID)
45+
/* NEON: Hook to determine if FPI should be suppressed for a WAL record
46+
* Returns true to suppress FPI, false to allow FPI
47+
* Applies to all resource managers for checkpoint-based FPI triggers.
4948
*/
50-
typedef bool (*xlog_fpi_control_hook_type)(RmgrId rmid);
51-
extern PGDLLIMPORT xlog_fpi_control_hook_type xlog_fpi_control_hook;
52-
53-
/* NEON: Flag set per-record to force disable FPI (set by neon_should_disable_fpi hook) */
54-
extern bool force_disable_full_page_write;
49+
typedef bool (*xlog_should_suppress_fpi_hook_type)(void);
50+
extern PGDLLIMPORT xlog_should_suppress_fpi_hook_type xlog_should_suppress_fpi_hook;
51+
52+
/* NEON: Flag set per-record to suppress FPI (set by xlog_should_suppress_fpi_hook) */
53+
extern bool suppress_fpi;
5554

5655
/* prototypes for public functions in xloginsert.c: */
5756
extern void XLogBeginInsert(void);

0 commit comments

Comments
 (0)