PG_AUTOCTL_SHOW_STATE(1)
πΈ PG_AUTOCTL SHOW STATE(1) πΈ
okay bestie, welcome to pg_autoctl show state β the pg_autoctl show state of all time. It's giving "let me tell you exactly what's happening in your failover formation" energy, and honestly? iconic. π
β¨ NAME β¨
pg_autoctl show state β pg_autoctl show state
pg_autoctl show state β Prints monitor's state of nodes in a given formation and group
β¨ SYNOPSIS β¨
So like, this command outputs the current state of the formation and groups registered to the pg_auto_failover monitor:
usage: pg_autoctl show state [ --pgdata --formation --group ]
--pgdata path to data directory
--monitor pg_auto_failover Monitor Postgres URL
--formation formation to query, defaults to 'default'
--group group to query formation, defaults to all
--local show local data, do not connect to the monitor
--watch display an auto-updating dashboard
--json output data in the JSON format
Quick lil vibe check on those flags, bestie:
--pgdataβ path to data directory--monitorβ pg_auto_failover Monitor Postgres URL--formationβ formation to query, defaults to'default'--groupβ group to query formation, defaults to all--localβ show local data, do not connect to the monitor--watchβ display an auto-updating dashboard--jsonβ output data in the JSON format
β¨ OPTIONS β¨
--pgdataβ Location of the Postgres node being managed locally. Defaults to the environment variablePGDATA. Use--monitorto connect to a monitor from anywhere, rather than the monitor URI used by a local Postgres node managed withpg_autoctl. ποΈ--monitorβ Postgres URI used to connect to the monitor. Must use theautoctl_nodeusername and target thepg_auto_failoverdatabase name. It is possible to show the Postgres URI from the monitor node using the commandpg_autoctl show uri. π--formationβ List the events recorded for nodes in the given formation. Defaults todefault. π--groupβ Limit output to a single group in the formation. Default to including all groups registered in the target formation. π--localβ Print the local state information without connecting to the monitor. π--watchβ Take control of the terminal and display the current state of the system and the last events from the monitor. The display is updated automatically every 500 milliseconds (half a second) and reacts properly to window size change. π
Depending on the terminal window size, a different set of columns is visible in the state part of the output. See pg_autoctl watch.
--jsonβ Output a JSON formatted data instead of a table formatted list. π€
β¨ ENVIRONMENT β¨
PGDATA
Postgres directory location. Can be used instead of the --pgdata option.
PG_AUTOCTL_MONITOR
Postgres URI to connect to the monitor node, can be used instead of the --monitor option.
XDG_CONFIG_HOME
The pg_autoctl command stores its configuration files in the standard place XDG_CONFIG_HOME. See the XDG Base Directory Specification. π
XDG_DATA_HOME
The pg_autoctl command stores its internal states files in the standard place XDG_DATA_HOME, which defaults to ~/.local/share. See the XDG Base Directory Specification. π
β¨ DESCRIPTION β¨
The pg_autoctl show state output includes the following columns, bestie β let's go one by one because each one is lowkey important:
- Name β Name of the node.
- Node β Node information. When the formation has a single group (group zero), then this column only contains the
nodeId.
Only Citus formations allow several groups. When using a Citus formation the Node column contains the groupId and the nodeId, separated by a colon, such as 0:1 for the first coordinator node.
- Host:Port β Hostname and port number used to connect to the node.
- TLI: LSN β Timeline identifier (TLI) and Postgres Log Sequence Number (LSN).
The LSN is the current position in the Postgres WAL stream. This is a hexadecimal number. See pg_lsn for more information.
The current timeline is incremented each time a failover happens, or when doing Point In Time Recovery. A node can only reach the secondary state when it is on the same timeline as its primary node.
- Connection β This output field contains two bits of information. First, the Postgres connection type that the node provides, either
read-writeorread-only. Then the mark!is added when the monitor has failed to connect to this node, and?when the monitor didn't connect to the node yet. - Reported State β The latest reported FSM state, as reported to the monitor by the
pg_autoctlprocess running on the Postgres node. - Assigned State β The assigned FSM state on the monitor. When the assigned state is not the same as the reported start, then the
pg_autoctlprocess running on the Postgres node might have not retrieved the assigned state yet, or might still be implementing the FSM transition from the current state to the assigned state.
β¨ EXAMPLES β¨
okay so here's the whole table moment, look at her:
$ pg_autoctl show state
Name | Node | Host:Port | TLI: LSN | Connection | Reported State | Assigned State
------+-------+----------------+----------------+--------------+---------------------+--------------------
node1 | 1 | localhost:5501 | 1: 0/4000678 | read-write | primary | primary
node2 | 2 | localhost:5502 | 1: 0/4000678 | read-only | secondary | secondary
node3 | 3 | localhost:5503 | 1: 0/4000678 | read-only | secondary | secondary
and then the --local serve, no monitor needed, she's self-sufficient:
$ pg_autoctl show state --local
Name | Node | Host:Port | TLI: LSN | Connection | Reported State | Assigned State
------+-------+----------------+----------------+--------------+---------------------+--------------------
node1 | 1 | localhost:5501 | 1: 0/4000678 | read-write ? | primary | primary
and for my data girlies, the --json version:
$ pg_autoctl show state --json
[
{
"health": 1,
"node_id": 1,
"group_id": 0,
"nodehost": "localhost",
"nodename": "node1",
"nodeport": 5501,
"reported_lsn": "0/4000678",
"reported_tli": 1,
"formation_kind": "pgsql",
"candidate_priority": 50,
"replication_quorum": true,
"current_group_state": "primary",
"assigned_group_state": "primary"
},
{
"health": 1,
"node_id": 2,
"group_id": 0,
"nodehost": "localhost",
"nodename": "node2",
"nodeport": 5502,
"reported_lsn": "0/4000678",
"reported_tli": 1,
"formation_kind": "pgsql",
"candidate_priority": 50,
"replication_quorum": true,
"current_group_state": "secondary",
"assigned_group_state": "secondary"
},
{
"health": 1,
"node_id": 3,
"group_id": 0,
"nodehost": "localhost",
"nodename": "node3",
"nodeport": 5503,
"reported_lsn": "0/4000678",
"reported_tli": 1,
"formation_kind": "pgsql",
"candidate_priority": 50,
"replication_quorum": true,
"current_group_state": "secondary",
"assigned_group_state": "secondary"
}
]
β¨ AUTHOR β¨
Microsoft π
β¨ COPYRIGHT β¨
Copyright (c) Microsoft Corporation. All rights reserved.
and that's the whole page, bestie π«Ά this was pg_auto_failover version 2.1, dated Jan 18, 2025, and honestly? she ate. go forth and show state responsibly π
β¨
π¦ where this page comes from
- fedora 43: pg_auto_failover 2.1-6.fc42 Β· Apache-1.0
- fedora 44: pg_auto_failover 2.1-6.fc42 Β· Apache-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms