v4-0001-Add-checkpoint-restartpoint-status-to-ps-display.patch
application/octet-stream
Filename: v4-0001-Add-checkpoint-restartpoint-status-to-ps-display.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch v4-0001
Subject: Add checkpoint/restartpoint status to ps display.
| File | + | − |
|---|---|---|
| src/backend/access/transam/xlog.c | 31 | 0 |
| src/backend/postmaster/checkpointer.c | 6 | 0 |
From befcf8b844fc602b6e038a04a03949ccb52f8b98 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <bossartn@amazon.com>
Date: Thu, 3 Dec 2020 21:10:48 +0000
Subject: [PATCH v4 1/1] Add checkpoint/restartpoint status to ps display.
---
src/backend/access/transam/xlog.c | 31 +++++++++++++++++++++++++++++++
src/backend/postmaster/checkpointer.c | 6 ++++++
2 files changed, 37 insertions(+)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 13f1d8c3dc..b36a3bb7cc 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8694,6 +8694,7 @@ CreateCheckPoint(int flags)
XLogRecPtr last_important_lsn;
VirtualTransactionId *vxids;
int nvxids;
+ char activitymsg[64];
/*
* An end-of-recovery checkpoint is really a shutdown checkpoint, just
@@ -8869,6 +8870,11 @@ CreateCheckPoint(int flags)
if (log_checkpoints)
LogCheckpointStart(flags, false);
+ snprintf(activitymsg, sizeof(activitymsg), "creating %s%scheckpoint",
+ (flags & CHECKPOINT_END_OF_RECOVERY) ? "end-of-recovery " : "",
+ (flags & CHECKPOINT_IS_SHUTDOWN) ? "shutdown " : "");
+ set_ps_display(activitymsg);
+
TRACE_POSTGRESQL_CHECKPOINT_START(flags);
/*
@@ -9084,6 +9090,16 @@ CreateCheckPoint(int flags)
/* Real work is done, but log and update stats before releasing lock. */
LogCheckpointEnd(false);
+ /*
+ * Reset the ps status display. We set the status to "idle" for the
+ * checkpointer process, and we clear it for anything else that runs this
+ * code.
+ */
+ if (MyBackendType == B_CHECKPOINTER)
+ set_ps_display("idle");
+ else
+ set_ps_display("");
+
TRACE_POSTGRESQL_CHECKPOINT_DONE(CheckpointStats.ckpt_bufs_written,
NBuffers,
CheckpointStats.ckpt_segs_added,
@@ -9246,6 +9262,7 @@ CreateRestartPoint(int flags)
XLogRecPtr endptr;
XLogSegNo _logSegNo;
TimestampTz xtime;
+ char activitymsg[64];
/*
* Acquire CheckpointLock to ensure only one restartpoint or checkpoint
@@ -9338,6 +9355,10 @@ CreateRestartPoint(int flags)
if (log_checkpoints)
LogCheckpointStart(flags, true);
+ snprintf(activitymsg, sizeof(activitymsg), "creating %srestartpoint",
+ (flags & CHECKPOINT_IS_SHUTDOWN) ? "shutdown " : "");
+ set_ps_display(activitymsg);
+
CheckPointGuts(lastCheckPoint.redo, flags);
/*
@@ -9456,6 +9477,16 @@ CreateRestartPoint(int flags)
/* Real work is done, but log and update before releasing lock. */
LogCheckpointEnd(true);
+ /*
+ * Reset the ps status display. We set the status to "idle" for the
+ * checkpointer process, and we clear it for anything else that runs this
+ * code.
+ */
+ if (MyBackendType == B_CHECKPOINTER)
+ set_ps_display("idle");
+ else
+ set_ps_display("");
+
xtime = GetLatestXTime();
ereport((log_checkpoints ? LOG : DEBUG2),
(errmsg("recovery restart point at %X/%X",
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index 429c8010ef..a0334c3b78 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -332,6 +332,12 @@ CheckpointerMain(void)
*/
ProcGlobal->checkpointerLatch = &MyProc->procLatch;
+ /*
+ * Initialize ps display. CreateCheckPoint() and CreateRestartPoint()
+ * handle updating it as needed.
+ */
+ set_ps_display("idle");
+
/*
* Loop forever
*/
--
2.16.6