@@ -94,6 +94,12 @@ int max_replication_apply_lag;
9494int max_replication_flush_lag ;
9595int 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 ;
99+
100+ /* NEON: Global flag to force disable FPI for current WAL record */
101+ bool force_disable_full_page_write = false;
102+
97103static registered_buffer * registered_buffers ;
98104static int max_registered_buffers ; /* allocated size */
99105static int max_registered_block_id = 0 ; /* highest block_id + 1 currently
@@ -516,6 +522,16 @@ XLogInsert(RmgrId rmid, uint8 info)
516522 */
517523 GetFullPageWriteInfo (& RedoRecPtr , & doPageWrites );
518524
525+ /*
526+ * NEON: Check if we should force disable FPI for this WAL record.
527+ */
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+ }
534+
519535 rdt = XLogRecordAssemble (rmid , info , RedoRecPtr , doPageWrites ,
520536 & fpw_lsn , & num_fpi , & topxid_included );
521537
@@ -616,9 +632,17 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
616632 */
617633 XLogRecPtr page_lsn = PageGetLSN (regbuf -> page );
618634
619- needs_backup = (page_lsn <= RedoRecPtr );
635+ if (force_disable_full_page_write )
636+ needs_backup = false;
637+ else
638+ needs_backup = (page_lsn <= RedoRecPtr );
639+
620640 if (!needs_backup )
621641 {
642+ /*
643+ * Set fpw_lsn to signal that this record should be
644+ * recomputed if doPageWrites changes.
645+ */
622646 if (* fpw_lsn == InvalidXLogRecPtr || page_lsn < * fpw_lsn )
623647 * fpw_lsn = page_lsn ;
624648 }
0 commit comments