From 2fd9b67b61fc1ded059500f468f0fa1824102a06 Mon Sep 17 00:00:00 2001
From: Tomas Vondra <tomas@vondra.me>
Date: Mon, 10 Mar 2025 14:56:14 +0100
Subject: [PATCH v20250314 2/6] review fixes

---
 doc/src/sgml/monitoring.sgml                 | 13 +++----------
 src/backend/catalog/system_views.sql         |  7 +++----
 src/backend/postmaster/datachecksumsworker.c | 11 +----------
 src/include/commands/progress.h              |  5 ++---
 src/include/miscadmin.h                      |  4 +++-
 src/test/regress/expected/rules.out          |  7 +++----
 6 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index e51bf902dc2..8fec0277f97 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -6911,7 +6911,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
        <para>
         The total number of databases which will be processed. Only the
         launcher worker has this value set, the other worker processes
-        have this <literal>NULL</literal>.
+        have this set to <literal>NULL</literal>.
        </para>
       </entry>
      </row>
@@ -6924,7 +6924,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
        <para>
         The number of databases which have been processed. Only the
         launcher worker has this value set, the other worker processes
-        have this <literal>NULL</literal>.
+        have this set to <literal>NULL</literal>.
        </para>
       </entry>
      </row>
@@ -7009,13 +7009,6 @@ FROM pg_stat_get_backend_idset() AS backendid;
        The command is currently disabling data checksums on the cluster.
       </entry>
      </row>
-     <row>
-      <entry><literal>waiting on backends</literal></entry>
-      <entry>
-       The command is currently waiting for backends to acknowledge the data
-       checksum operation.
-      </entry>
-     </row>
      <row>
       <entry><literal>waiting on temporary tables</literal></entry>
       <entry>
@@ -7027,7 +7020,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
       <entry><literal>waiting on checkpoint</literal></entry>
       <entry>
        The command is currently waiting for a checkpoint to update the checksum
-       state at the end.
+       state before finishing.
       </entry>
      </row>
     </tbody>
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index 4330d0ad656..6ffd31ce39c 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -1340,10 +1340,9 @@ CREATE VIEW pg_stat_progress_data_checksums AS
         CASE S.param1 WHEN 0 THEN 'enabling'
                       WHEN 1 THEN 'disabling'
                       WHEN 2 THEN 'waiting'
-                      WHEN 3 THEN 'waiting on backends'
-                      WHEN 4 THEN 'waiting on temporary tables'
-                      WHEN 5 THEN 'waiting on checkpoint'
-                      WHEN 6 THEN 'done'
+                      WHEN 3 THEN 'waiting on temporary tables'
+                      WHEN 4 THEN 'waiting on checkpoint'
+                      WHEN 5 THEN 'done'
                       END AS phase,
         CASE S.param2 WHEN -1 THEN NULL ELSE S.param2 END AS databases_total,
         S.param3 AS databases_done,
diff --git a/src/backend/postmaster/datachecksumsworker.c b/src/backend/postmaster/datachecksumsworker.c
index bbbce61cfa6..d9833cd4c98 100644
--- a/src/backend/postmaster/datachecksumsworker.c
+++ b/src/backend/postmaster/datachecksumsworker.c
@@ -801,15 +801,6 @@ again:
 		}
 		RESUME_INTERRUPTS();
 
-		/*
-		 * Initialize progress and indicate that we are waiting on the other
-		 * backends to clear the procsignalbarrier.
-		 */
-		pgstat_progress_update_param(PROGRESS_DATACHECKSUMS_PHASE,
-									 PROGRESS_DATACHECKSUMS_PHASE_WAITING_BACKENDS);
-
-		/* XXX isn't it weird there's no wait between the phase updates? */
-
 		/*
 		 * Set the state to inprogress-on and wait on the procsignal barrier.
 		 */
@@ -1083,7 +1074,7 @@ ProcessAllDatabases(bool immediate_checkpoint)
 
 	/*
 	 * When enabling checksums, we have to wait for a checkpoint for the
-	 * checksums to e.
+	 * checksums to change from in-progress to on.
 	 */
 	pgstat_progress_update_param(PROGRESS_DATACHECKSUMS_PHASE,
 								 PROGRESS_DATACHECKSUMS_PHASE_WAITING_CHECKPOINT);
diff --git a/src/include/commands/progress.h b/src/include/commands/progress.h
index 94b478a6cc9..b172a5f24ce 100644
--- a/src/include/commands/progress.h
+++ b/src/include/commands/progress.h
@@ -170,8 +170,7 @@
 #define PROGRESS_DATACHECKSUMS_PHASE_ENABLING			0
 #define PROGRESS_DATACHECKSUMS_PHASE_DISABLING			1
 #define PROGRESS_DATACHECKSUMS_PHASE_WAITING			2
-#define PROGRESS_DATACHECKSUMS_PHASE_WAITING_BACKENDS	3
-#define PROGRESS_DATACHECKSUMS_PHASE_WAITING_TEMPREL	4
-#define PROGRESS_DATACHECKSUMS_PHASE_WAITING_CHECKPOINT 5
+#define PROGRESS_DATACHECKSUMS_PHASE_WAITING_TEMPREL	3
+#define PROGRESS_DATACHECKSUMS_PHASE_WAITING_CHECKPOINT 4
 
 #endif
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index c238c31604c..677d0b45bd4 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -392,7 +392,9 @@ extern PGDLLIMPORT BackendType MyBackendType;
 #define AmWalReceiverProcess()		(MyBackendType == B_WAL_RECEIVER)
 #define AmWalSummarizerProcess()	(MyBackendType == B_WAL_SUMMARIZER)
 #define AmWalWriterProcess()		(MyBackendType == B_WAL_WRITER)
-#define AmDataChecksumsWorkerProcess()	(MyBackendType == B_DATACHECKSUMSWORKER_LAUNCHER || MyBackendType == B_DATACHECKSUMSWORKER_WORKER)
+#define AmDataChecksumsWorkerProcess() \
+	(MyBackendType == B_DATACHECKSUMSWORKER_LAUNCHER || \
+	 MyBackendType == B_DATACHECKSUMSWORKER_WORKER)
 
 #define AmSpecialWorkerProcess() \
 	(AmAutoVacuumLauncherProcess() || \
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index 2cfea837554..0dd383a76dd 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -2048,10 +2048,9 @@ pg_stat_progress_data_checksums| SELECT s.pid,
             WHEN 0 THEN 'enabling'::text
             WHEN 1 THEN 'disabling'::text
             WHEN 2 THEN 'waiting'::text
-            WHEN 3 THEN 'waiting on backends'::text
-            WHEN 4 THEN 'waiting on temporary tables'::text
-            WHEN 5 THEN 'waiting on checkpoint'::text
-            WHEN 6 THEN 'done'::text
+            WHEN 3 THEN 'waiting on temporary tables'::text
+            WHEN 4 THEN 'waiting on checkpoint'::text
+            WHEN 5 THEN 'done'::text
             ELSE NULL::text
         END AS phase,
         CASE s.param2
-- 
2.39.3 (Apple Git-146)

