1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-20 05:03:10 +03:00

Rename CHECKPOINT_IMMEDIATE to CHECKPOINT_FAST.

The new name more accurately reflects the effects of this flag on a
requested checkpoint.  Checkpoint-related log messages (i.e., those
controlled by the log_checkpoints configuration parameter) will now
say "fast" instead of "immediate", too.  Likewise, references to
"immediate" checkpoints in the documentation have been updated to
say "fast".  This is preparatory work for a follow-up commit that
will add a MODE option to the CHECKPOINT command.

Author: Christoph Berg <myon@debian.org>
Discussion: https://postgr.es/m/aDnaKTEf-0dLiEfz%40msg.df7cb.de
This commit is contained in:
Nathan Bossart
2025-07-11 11:51:25 -05:00
parent cd8324cc89
commit bb938e2c3c
12 changed files with 40 additions and 40 deletions

View File

@ -991,7 +991,7 @@ SELECT pg_backup_start(label => 'label', fast => false);
usually preferable as it minimizes the impact on the running system. If you usually preferable as it minimizes the impact on the running system. If you
want to start the backup as soon as possible, pass <literal>true</literal> as want to start the backup as soon as possible, pass <literal>true</literal> as
the second parameter to <function>pg_backup_start</function> and it will the second parameter to <function>pg_backup_start</function> and it will
request an immediate checkpoint, which will finish as fast as possible using request a fast checkpoint, which will finish as fast as possible using
as much I/O as possible. as much I/O as possible.
</para> </para>

View File

@ -28973,7 +28973,7 @@ LOG: Grand total: 1651920 bytes in 201 blocks; 622360 free (88 chunks); 1029560
will be stored.) will be stored.)
If the optional second parameter is given as <literal>true</literal>, If the optional second parameter is given as <literal>true</literal>,
it specifies executing <function>pg_backup_start</function> as quickly it specifies executing <function>pg_backup_start</function> as quickly
as possible. This forces an immediate checkpoint which will cause a as possible. This forces a fast checkpoint which will cause a
spike in I/O operations, slowing any concurrently executing queries. spike in I/O operations, slowing any concurrently executing queries.
</para> </para>
<para> <para>

View File

@ -37,7 +37,7 @@ CHECKPOINT
</para> </para>
<para> <para>
The <command>CHECKPOINT</command> command forces an immediate The <command>CHECKPOINT</command> command forces a fast
checkpoint when the command is issued, without waiting for a checkpoint when the command is issued, without waiting for a
regular checkpoint scheduled by the system (controlled by the settings in regular checkpoint scheduled by the system (controlled by the settings in
<xref linkend="runtime-config-wal-checkpoints"/>). <xref linkend="runtime-config-wal-checkpoints"/>).

View File

@ -500,8 +500,9 @@ PostgreSQL documentation
<term><option>--checkpoint={fast|spread}</option></term> <term><option>--checkpoint={fast|spread}</option></term>
<listitem> <listitem>
<para> <para>
Sets checkpoint mode to fast (immediate) or spread (the default) Sets checkpoint mode to fast or spread
(see <xref linkend="backup-lowlevel-base-backup"/>). (see <xref linkend="backup-lowlevel-base-backup"/>).
The default is spread.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@ -6486,7 +6486,7 @@ PerformRecoveryXLogAction(void)
else else
{ {
RequestCheckpoint(CHECKPOINT_END_OF_RECOVERY | RequestCheckpoint(CHECKPOINT_END_OF_RECOVERY |
CHECKPOINT_IMMEDIATE | CHECKPOINT_FAST |
CHECKPOINT_WAIT); CHECKPOINT_WAIT);
} }
@ -6795,7 +6795,7 @@ ShutdownXLOG(int code, Datum arg)
WalSndWaitStopping(); WalSndWaitStopping();
if (RecoveryInProgress()) if (RecoveryInProgress())
CreateRestartPoint(CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_IMMEDIATE); CreateRestartPoint(CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_FAST);
else else
{ {
/* /*
@ -6807,7 +6807,7 @@ ShutdownXLOG(int code, Datum arg)
if (XLogArchivingActive()) if (XLogArchivingActive())
RequestXLogSwitch(false); RequestXLogSwitch(false);
CreateCheckPoint(CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_IMMEDIATE); CreateCheckPoint(CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_FAST);
} }
} }
@ -6823,7 +6823,7 @@ LogCheckpointStart(int flags, bool restartpoint)
(errmsg("restartpoint starting:%s%s%s%s%s%s%s%s", (errmsg("restartpoint starting:%s%s%s%s%s%s%s%s",
(flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "", (flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "",
(flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "", (flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "",
(flags & CHECKPOINT_IMMEDIATE) ? " immediate" : "", (flags & CHECKPOINT_FAST) ? " fast" : "",
(flags & CHECKPOINT_FORCE) ? " force" : "", (flags & CHECKPOINT_FORCE) ? " force" : "",
(flags & CHECKPOINT_WAIT) ? " wait" : "", (flags & CHECKPOINT_WAIT) ? " wait" : "",
(flags & CHECKPOINT_CAUSE_XLOG) ? " wal" : "", (flags & CHECKPOINT_CAUSE_XLOG) ? " wal" : "",
@ -6835,7 +6835,7 @@ LogCheckpointStart(int flags, bool restartpoint)
(errmsg("checkpoint starting:%s%s%s%s%s%s%s%s", (errmsg("checkpoint starting:%s%s%s%s%s%s%s%s",
(flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "", (flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "",
(flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "", (flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "",
(flags & CHECKPOINT_IMMEDIATE) ? " immediate" : "", (flags & CHECKPOINT_FAST) ? " fast" : "",
(flags & CHECKPOINT_FORCE) ? " force" : "", (flags & CHECKPOINT_FORCE) ? " force" : "",
(flags & CHECKPOINT_WAIT) ? " wait" : "", (flags & CHECKPOINT_WAIT) ? " wait" : "",
(flags & CHECKPOINT_CAUSE_XLOG) ? " wal" : "", (flags & CHECKPOINT_CAUSE_XLOG) ? " wal" : "",
@ -7023,8 +7023,8 @@ update_checkpoint_display(int flags, bool restartpoint, bool reset)
* flags is a bitwise OR of the following: * flags is a bitwise OR of the following:
* CHECKPOINT_IS_SHUTDOWN: checkpoint is for database shutdown. * CHECKPOINT_IS_SHUTDOWN: checkpoint is for database shutdown.
* CHECKPOINT_END_OF_RECOVERY: checkpoint is for end of WAL recovery. * CHECKPOINT_END_OF_RECOVERY: checkpoint is for end of WAL recovery.
* CHECKPOINT_IMMEDIATE: finish the checkpoint ASAP, * CHECKPOINT_FAST: finish the checkpoint ASAP, ignoring
* ignoring checkpoint_completion_target parameter. * checkpoint_completion_target parameter.
* CHECKPOINT_FORCE: force a checkpoint even if no XLOG activity has occurred * CHECKPOINT_FORCE: force a checkpoint even if no XLOG activity has occurred
* since the last one (implied by CHECKPOINT_IS_SHUTDOWN or * since the last one (implied by CHECKPOINT_IS_SHUTDOWN or
* CHECKPOINT_END_OF_RECOVERY). * CHECKPOINT_END_OF_RECOVERY).
@ -8929,9 +8929,8 @@ issue_xlog_fsync(int fd, XLogSegNo segno, TimeLineID tli)
* backup state and tablespace map. * backup state and tablespace map.
* *
* Input parameters are "state" (the backup state), "fast" (if true, we do * Input parameters are "state" (the backup state), "fast" (if true, we do
* the checkpoint in immediate mode to make it faster), and "tablespaces" * the checkpoint in fast mode), and "tablespaces" (if non-NULL, indicates a
* (if non-NULL, indicates a list of tablespaceinfo structs describing the * list of tablespaceinfo structs describing the cluster's tablespaces.).
* cluster's tablespaces.).
* *
* The tablespace map contents are appended to passed-in parameter * The tablespace map contents are appended to passed-in parameter
* tablespace_map and the caller is responsible for including it in the backup * tablespace_map and the caller is responsible for including it in the backup
@ -9059,11 +9058,11 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
* during recovery means that checkpointer is running, we can use * during recovery means that checkpointer is running, we can use
* RequestCheckpoint() to establish a restartpoint. * RequestCheckpoint() to establish a restartpoint.
* *
* We use CHECKPOINT_IMMEDIATE only if requested by user (via * We use CHECKPOINT_FAST only if requested by user (via passing
* passing fast = true). Otherwise this can take awhile. * fast = true). Otherwise this can take awhile.
*/ */
RequestCheckpoint(CHECKPOINT_FORCE | CHECKPOINT_WAIT | RequestCheckpoint(CHECKPOINT_FORCE | CHECKPOINT_WAIT |
(fast ? CHECKPOINT_IMMEDIATE : 0)); (fast ? CHECKPOINT_FAST : 0));
/* /*
* Now we need to fetch the checkpoint record location, and also * Now we need to fetch the checkpoint record location, and also

View File

@ -570,7 +570,7 @@ CreateDatabaseUsingFileCopy(Oid src_dboid, Oid dst_dboid, Oid src_tsid,
* any CREATE DATABASE commands. * any CREATE DATABASE commands.
*/ */
if (!IsBinaryUpgrade) if (!IsBinaryUpgrade)
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | RequestCheckpoint(CHECKPOINT_FAST | CHECKPOINT_FORCE |
CHECKPOINT_WAIT | CHECKPOINT_FLUSH_UNLOGGED); CHECKPOINT_WAIT | CHECKPOINT_FLUSH_UNLOGGED);
/* /*
@ -673,7 +673,7 @@ CreateDatabaseUsingFileCopy(Oid src_dboid, Oid dst_dboid, Oid src_tsid,
* strategy that avoids these problems. * strategy that avoids these problems.
*/ */
if (!IsBinaryUpgrade) if (!IsBinaryUpgrade)
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | RequestCheckpoint(CHECKPOINT_FAST | CHECKPOINT_FORCE |
CHECKPOINT_WAIT); CHECKPOINT_WAIT);
} }
@ -1870,7 +1870,7 @@ dropdb(const char *dbname, bool missing_ok, bool force)
* Force a checkpoint to make sure the checkpointer has received the * Force a checkpoint to make sure the checkpointer has received the
* message sent by ForgetDatabaseSyncRequests. * message sent by ForgetDatabaseSyncRequests.
*/ */
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT); RequestCheckpoint(CHECKPOINT_FAST | CHECKPOINT_FORCE | CHECKPOINT_WAIT);
/* Close all smgr fds in all backends. */ /* Close all smgr fds in all backends. */
WaitForProcSignalBarrier(EmitProcSignalBarrier(PROCSIGNAL_BARRIER_SMGRRELEASE)); WaitForProcSignalBarrier(EmitProcSignalBarrier(PROCSIGNAL_BARRIER_SMGRRELEASE));
@ -2120,7 +2120,7 @@ movedb(const char *dbname, const char *tblspcname)
* On Windows, this also ensures that background procs don't hold any open * On Windows, this also ensures that background procs don't hold any open
* files, which would cause rmdir() to fail. * files, which would cause rmdir() to fail.
*/ */
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT RequestCheckpoint(CHECKPOINT_FAST | CHECKPOINT_FORCE | CHECKPOINT_WAIT
| CHECKPOINT_FLUSH_UNLOGGED); | CHECKPOINT_FLUSH_UNLOGGED);
/* Close all smgr fds in all backends. */ /* Close all smgr fds in all backends. */
@ -2252,7 +2252,7 @@ movedb(const char *dbname, const char *tblspcname)
* any unlogged operations done in the new DB tablespace before the * any unlogged operations done in the new DB tablespace before the
* next checkpoint. * next checkpoint.
*/ */
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT); RequestCheckpoint(CHECKPOINT_FAST | CHECKPOINT_FORCE | CHECKPOINT_WAIT);
/* /*
* Force synchronous commit, thus minimizing the window between * Force synchronous commit, thus minimizing the window between

View File

@ -500,7 +500,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
* mustn't delete. So instead, we force a checkpoint which will clean * mustn't delete. So instead, we force a checkpoint which will clean
* out any lingering files, and try again. * out any lingering files, and try again.
*/ */
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT); RequestCheckpoint(CHECKPOINT_FAST | CHECKPOINT_FORCE | CHECKPOINT_WAIT);
/* /*
* On Windows, an unlinked file persists in the directory listing * On Windows, an unlinked file persists in the directory listing

View File

@ -161,7 +161,7 @@ static pg_time_t last_xlog_switch_time;
static void ProcessCheckpointerInterrupts(void); static void ProcessCheckpointerInterrupts(void);
static void CheckArchiveTimeout(void); static void CheckArchiveTimeout(void);
static bool IsCheckpointOnSchedule(double progress); static bool IsCheckpointOnSchedule(double progress);
static bool ImmediateCheckpointRequested(void); static bool FastCheckpointRequested(void);
static bool CompactCheckpointerRequestQueue(void); static bool CompactCheckpointerRequestQueue(void);
static void UpdateSharedMemoryConfig(void); static void UpdateSharedMemoryConfig(void);
@ -734,12 +734,12 @@ CheckArchiveTimeout(void)
} }
/* /*
* Returns true if an immediate checkpoint request is pending. (Note that * Returns true if a fast checkpoint request is pending. (Note that this does
* this does not check the *current* checkpoint's IMMEDIATE flag, but whether * not check the *current* checkpoint's FAST flag, but whether there is one
* there is one pending behind it.) * pending behind it.)
*/ */
static bool static bool
ImmediateCheckpointRequested(void) FastCheckpointRequested(void)
{ {
volatile CheckpointerShmemStruct *cps = CheckpointerShmem; volatile CheckpointerShmemStruct *cps = CheckpointerShmem;
@ -747,7 +747,7 @@ ImmediateCheckpointRequested(void)
* We don't need to acquire the ckpt_lck in this case because we're only * We don't need to acquire the ckpt_lck in this case because we're only
* looking at a single flag bit. * looking at a single flag bit.
*/ */
if (cps->ckpt_flags & CHECKPOINT_IMMEDIATE) if (cps->ckpt_flags & CHECKPOINT_FAST)
return true; return true;
return false; return false;
} }
@ -760,7 +760,7 @@ ImmediateCheckpointRequested(void)
* checkpoint_completion_target. * checkpoint_completion_target.
* *
* The checkpoint request flags should be passed in; currently the only one * The checkpoint request flags should be passed in; currently the only one
* examined is CHECKPOINT_IMMEDIATE, which disables delays between writes. * examined is CHECKPOINT_FAST, which disables delays between writes.
* *
* 'progress' is an estimate of how much of the work has been done, as a * 'progress' is an estimate of how much of the work has been done, as a
* fraction between 0.0 meaning none, and 1.0 meaning all done. * fraction between 0.0 meaning none, and 1.0 meaning all done.
@ -778,10 +778,10 @@ CheckpointWriteDelay(int flags, double progress)
* Perform the usual duties and take a nap, unless we're behind schedule, * Perform the usual duties and take a nap, unless we're behind schedule,
* in which case we just try to catch up as quickly as possible. * in which case we just try to catch up as quickly as possible.
*/ */
if (!(flags & CHECKPOINT_IMMEDIATE) && if (!(flags & CHECKPOINT_FAST) &&
!ShutdownXLOGPending && !ShutdownXLOGPending &&
!ShutdownRequestPending && !ShutdownRequestPending &&
!ImmediateCheckpointRequested() && !FastCheckpointRequested() &&
IsCheckpointOnSchedule(progress)) IsCheckpointOnSchedule(progress))
{ {
if (ConfigReloadPending) if (ConfigReloadPending)
@ -983,11 +983,11 @@ CheckpointerShmemInit(void)
* flags is a bitwise OR of the following: * flags is a bitwise OR of the following:
* CHECKPOINT_IS_SHUTDOWN: checkpoint is for database shutdown. * CHECKPOINT_IS_SHUTDOWN: checkpoint is for database shutdown.
* CHECKPOINT_END_OF_RECOVERY: checkpoint is for end of WAL recovery. * CHECKPOINT_END_OF_RECOVERY: checkpoint is for end of WAL recovery.
* CHECKPOINT_IMMEDIATE: finish the checkpoint ASAP, * CHECKPOINT_FAST: finish the checkpoint ASAP,
* ignoring checkpoint_completion_target parameter. * ignoring checkpoint_completion_target parameter.
* CHECKPOINT_FORCE: force a checkpoint even if no XLOG activity has occurred * CHECKPOINT_FORCE: force a checkpoint even if no XLOG activity has occurred
* since the last one (implied by CHECKPOINT_IS_SHUTDOWN or * since the last one (implied by CHECKPOINT_IS_SHUTDOWN or
* CHECKPOINT_END_OF_RECOVERY). * CHECKPOINT_END_OF_RECOVERY, and the CHECKPOINT command).
* CHECKPOINT_WAIT: wait for completion before returning (otherwise, * CHECKPOINT_WAIT: wait for completion before returning (otherwise,
* just signal checkpointer to do it, and return). * just signal checkpointer to do it, and return).
* CHECKPOINT_CAUSE_XLOG: checkpoint is requested due to xlog filling. * CHECKPOINT_CAUSE_XLOG: checkpoint is requested due to xlog filling.
@ -1009,7 +1009,7 @@ RequestCheckpoint(int flags)
* There's no point in doing slow checkpoints in a standalone backend, * There's no point in doing slow checkpoints in a standalone backend,
* because there's no other backends the checkpoint could disrupt. * because there's no other backends the checkpoint could disrupt.
*/ */
CreateCheckPoint(flags | CHECKPOINT_IMMEDIATE); CreateCheckPoint(flags | CHECKPOINT_FAST);
/* Free all smgr objects, as CheckpointerMain() normally would. */ /* Free all smgr objects, as CheckpointerMain() normally would. */
smgrdestroyall(); smgrdestroyall();

View File

@ -3339,8 +3339,8 @@ UnpinBufferNoOwner(BufferDesc *buf)
* BufferSync -- Write out all dirty buffers in the pool. * BufferSync -- Write out all dirty buffers in the pool.
* *
* This is called at checkpoint time to write out all dirty shared buffers. * This is called at checkpoint time to write out all dirty shared buffers.
* The checkpoint request flags should be passed in. If CHECKPOINT_IMMEDIATE * The checkpoint request flags should be passed in. If CHECKPOINT_FAST is
* is set, we disable delays between writes; if CHECKPOINT_IS_SHUTDOWN, * set, we disable delays between writes; if CHECKPOINT_IS_SHUTDOWN,
* CHECKPOINT_END_OF_RECOVERY or CHECKPOINT_FLUSH_UNLOGGED is set, we write * CHECKPOINT_END_OF_RECOVERY or CHECKPOINT_FLUSH_UNLOGGED is set, we write
* even unlogged buffers, which are otherwise skipped. The remaining flags * even unlogged buffers, which are otherwise skipped. The remaining flags
* currently have no effect here. * currently have no effect here.

View File

@ -952,7 +952,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
errdetail("Only roles with privileges of the \"%s\" role may execute this command.", errdetail("Only roles with privileges of the \"%s\" role may execute this command.",
"pg_checkpoint"))); "pg_checkpoint")));
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_WAIT | RequestCheckpoint(CHECKPOINT_FAST | CHECKPOINT_WAIT |
(RecoveryInProgress() ? 0 : CHECKPOINT_FORCE)); (RecoveryInProgress() ? 0 : CHECKPOINT_FORCE));
break; break;

View File

@ -139,7 +139,7 @@ extern PGDLLIMPORT bool XLOG_DEBUG;
#define CHECKPOINT_IS_SHUTDOWN 0x0001 /* Checkpoint is for shutdown */ #define CHECKPOINT_IS_SHUTDOWN 0x0001 /* Checkpoint is for shutdown */
#define CHECKPOINT_END_OF_RECOVERY 0x0002 /* Like shutdown checkpoint, but #define CHECKPOINT_END_OF_RECOVERY 0x0002 /* Like shutdown checkpoint, but
* issued at end of WAL recovery */ * issued at end of WAL recovery */
#define CHECKPOINT_IMMEDIATE 0x0004 /* Do it without delays */ #define CHECKPOINT_FAST 0x0004 /* Do it without delays */
#define CHECKPOINT_FORCE 0x0008 /* Force even if no activity */ #define CHECKPOINT_FORCE 0x0008 /* Force even if no activity */
#define CHECKPOINT_FLUSH_UNLOGGED 0x0010 /* Flush unlogged tables */ #define CHECKPOINT_FLUSH_UNLOGGED 0x0010 /* Flush unlogged tables */
/* These are important to RequestCheckpoint */ /* These are important to RequestCheckpoint */

View File

@ -91,7 +91,7 @@ $node_standby->wait_for_event('checkpointer', 'create-restart-point');
# Check the logs that the restart point has started on standby. This is # Check the logs that the restart point has started on standby. This is
# optional, but let's be sure. # optional, but let's be sure.
ok( $node_standby->log_contains( ok( $node_standby->log_contains(
"restartpoint starting: immediate wait", $logstart), "restartpoint starting: fast wait", $logstart),
"restartpoint has started"); "restartpoint has started");
# Trigger promotion during the restart point. # Trigger promotion during the restart point.