Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/backend/access/transam/xlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ set_lwlsn_db_hook_type set_lwlsn_db_hook = NULL;
set_lwlsn_relation_hook_type set_lwlsn_relation_hook = NULL;
set_max_lwlsn_hook_type set_max_lwlsn_hook = NULL;

/* NEON: Hook to control checkpoint buffer flushing */
checkpoint_buffers_hook_type checkpoint_buffers_hook = NULL;

/*
* Number of WAL insertion locks to use. A higher value allows more insertions
* to happen concurrently, but adds some CPU overhead to flushing the WAL,
Expand Down Expand Up @@ -7685,7 +7688,10 @@ PreCheckPointGuts(int flags)
if (flags & (CHECKPOINT_IS_SHUTDOWN|CHECKPOINT_END_OF_RECOVERY))
{
CheckPointReplicationState(flags);
CheckPointBuffers(flags);

/* NEON: Allow extension to control checkpoint buffer flushing */
if (!checkpoint_buffers_hook || checkpoint_buffers_hook())
CheckPointBuffers(flags);

/*
* pgstat_write_statsfile will be called later by before_shmem_exit() hook, but by then it's too late
Expand Down Expand Up @@ -7721,8 +7727,13 @@ CheckPointGuts(XLogRecPtr checkPointRedo, int flags)
* wallog FSM/VM pages to persist them at page server.
* Writing to the WAL during shutdown checkpoint cause Postgres panic.
* So do it before in PreCheckPointGuts.
*
* The checkpoint_buffers_hook allows extensions (e.g., Neon) to control
* whether buffer flushing should proceed, as bgwriter and buffer eviction
* also handle FSM/VM flushing.
*/
if (!(flags & (CHECKPOINT_IS_SHUTDOWN|CHECKPOINT_END_OF_RECOVERY)))
if ((!(flags & (CHECKPOINT_IS_SHUTDOWN|CHECKPOINT_END_OF_RECOVERY))) &&
(!checkpoint_buffers_hook || checkpoint_buffers_hook()))
CheckPointBuffers(flags);

/* Perform all queued up fsyncs */
Expand Down
4 changes: 4 additions & 0 deletions src/include/access/xlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ extern set_lwlsn_db_hook_type set_lwlsn_db_hook;
extern set_lwlsn_relation_hook_type set_lwlsn_relation_hook;
extern set_max_lwlsn_hook_type set_max_lwlsn_hook;

/* NEON: Hook to control checkpoint buffer flushing */
typedef bool (*checkpoint_buffers_hook_type) (void);
extern checkpoint_buffers_hook_type checkpoint_buffers_hook;

/*
* Routines used by xlogrecovery.c to call back into xlog.c during recovery.
*/
Expand Down