aboutsummaryrefslogtreecommitdiff
path: root/src/include/pgstat.h
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-03-26 22:02:22 -0400
committerRobert Haas <rhaas@postgresql.org>2017-03-26 22:02:22 -0400
commitfc70a4b0df38bda6a13941f1581f25fbb643c7f3 (patch)
tree87ee4eec5f4bc96bacad8e8c5313abc5f9c3f367 /src/include/pgstat.h
parent2f0903ea196503fc8af373a9de46b1e01a23508c (diff)
downloadpostgresql-fc70a4b0df38bda6a13941f1581f25fbb643c7f3.tar.gz
postgresql-fc70a4b0df38bda6a13941f1581f25fbb643c7f3.zip
Show more processes in pg_stat_activity.
Previously, auxiliary processes and background workers not connected to a database (such as the logical replication launcher) weren't shown. Include them, so that we can see the associated wait state information. Add a new column to identify the processes type, so that people can filter them out easily using SQL if they wish. Before this patch was written, there was discussion about whether we should expose this information in a separate view, so as to avoid contaminating pg_stat_activity with things people might not want to see. But putting everything in pg_stat_activity was a more popular choice, so that's what the patch does. Kuntal Ghosh, reviewed by Amit Langote and Michael Paquier. Some revisions and bug fixes by me. Discussion: http://postgr.es/m/CA+TgmoYES5nhkEGw9nZXU8_FhA8XEm8NTm3-SO+3ML1B81Hkww@mail.gmail.com
Diffstat (limited to 'src/include/pgstat.h')
-rw-r--r--src/include/pgstat.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 201562521f7..e29397f25b8 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -696,6 +696,25 @@ typedef struct PgStat_GlobalStats
/* ----------
+ * Backend types
+ * ----------
+ */
+typedef enum BackendType
+{
+ B_AUTOVAC_LAUNCHER,
+ B_AUTOVAC_WORKER,
+ B_BACKEND,
+ B_BG_WORKER,
+ B_BG_WRITER,
+ B_CHECKPOINTER,
+ B_STARTUP,
+ B_WAL_RECEIVER,
+ B_WAL_SENDER,
+ B_WAL_WRITER
+} BackendType;
+
+
+/* ----------
* Backend states
* ----------
*/
@@ -927,6 +946,9 @@ typedef struct PgBackendSSLStatus
* showing its current activity. (The structs are allocated according to
* BackendId, but that is not critical.) Note that the collector process
* has no involvement in, or even access to, these structs.
+ *
+ * Each auxiliary process also maintains a PgBackendStatus struct in shared
+ * memory.
* ----------
*/
typedef struct PgBackendStatus
@@ -951,6 +973,9 @@ typedef struct PgBackendStatus
/* The entry is valid iff st_procpid > 0, unused if st_procpid == 0 */
int st_procpid;
+ /* Type of backends */
+ BackendType st_backendType;
+
/* Times when current backend, transaction, and activity started */
TimestampTz st_proc_start_timestamp;
TimestampTz st_xact_start_timestamp;
@@ -1149,6 +1174,7 @@ extern const char *pgstat_get_wait_event_type(uint32 wait_event_info);
extern const char *pgstat_get_backend_current_activity(int pid, bool checkUser);
extern const char *pgstat_get_crashed_backend_activity(int pid, char *buffer,
int buflen);
+extern const char *pgstat_get_backend_desc(BackendType backendType);
extern void pgstat_progress_start_command(ProgressCommandType cmdtype,
Oid relid);