PG_AUTOCTL ENABLE MAINTENANCE(1)
β¨ NAME β¨
okay bestie, so this is pg_autoctl enable maintenance β and it's literally the command that flips Postgres maintenance mode ON for this node. π
It's part of the pg_auto_failover crew, and this page is the <red>pg_autoctl enable maintenance</red>(1) manual. Welcome, you're gonna love it here. π
πΈ SYNOPSIS πΈ
A pg_auto_failover node can be put into a maintenance state, and honestly? It's giving "brb don't touch me." π«Ά While it's in there, the Postgres node is still registered to the monitor, but the monitor knows it's unreliable until maintenance gets disabled. And the big one, no cap: a node in the maintenance state is not a candidate for promotion. π
Typical glow-up reasons you'd use maintenance state: an Operating System or Postgres reboot β like when you're applying security upgrades. π
usage: pg_autoctl enable maintenance [ --pgdata --allow-failover ]
--pgdata path to data directory
β OPTIONS β
--pgdataβ where the Postgres node that's being managed locally lives. Defaults to the environment variablePGDATA. Also, heads up: use--monitorto connect to a monitor from anywhere, instead of the monitor URI that a local Postgres node managed withpg_autoctlwould use. π--formationβ the target formation where you wanna enable the secondary feature. π¦
π§ ENVIRONMENT π§
PGDATAβ Postgres directory location. You can use this instead of the--pgdataoption. β¨PG_AUTOCTL_MONITORβ Postgres URI to connect to the monitor node. Can be used instead of the--monitoroption. πXDG_CONFIG_HOMEβ thepg_autoctlcommand stores its configuration files in the standard placeXDG_CONFIG_HOME. See the XDG Base Directory Specification. πXDG_DATA_HOMEβ thepg_autoctlcommand stores its internal states files in the standard placeXDG_DATA_HOME, which defaults to~/.local/share. See the XDG Base Directory Specification. π
π EXAMPLES π
okay so first, vibe check the cluster:
pg_autoctl show state
Name | Node | Host:Port | LSN | Connection | Current State | Assigned State
------+-------+----------------+-----------+--------------+---------------------+--------------------
node1 | 1 | localhost:5501 | 0/4000760 | read-write | primary | primary
node2 | 2 | localhost:5502 | 0/4000760 | read-only | secondary | secondary
node3 | 3 | localhost:5503 | 0/4000760 | read-only | secondary | secondary
now watch node3 go take its little nap π΄:
$ pg_autoctl enable maintenance --pgdata node3
12:06:12 47086 INFO Listening monitor notifications about state changes in formation "default" and group 0
12:06:12 47086 INFO Following table displays times when notifications are received
Time | Name | Node | Host:Port | Current State | Assigned State
---------+-------+-------+----------------+---------------------+--------------------
12:06:12 | node1 | 1 | localhost:5501 | primary | join_primary
12:06:12 | node3 | 3 | localhost:5503 | secondary | wait_maintenance
12:06:12 | node3 | 3 | localhost:5503 | wait_maintenance | wait_maintenance
12:06:12 | node1 | 1 | localhost:5501 | join_primary | join_primary
12:06:12 | node3 | 3 | localhost:5503 | wait_maintenance | maintenance
12:06:12 | node1 | 1 | localhost:5501 | join_primary | primary
12:06:13 | node3 | 3 | localhost:5503 | maintenance | maintenance
and then check the state again, look at her π:
$ pg_autoctl show state
Name | Node | Host:Port | LSN | Connection | Current State | Assigned State
------+-------+----------------+-----------+--------------+---------------------+--------------------
node1 | 1 | localhost:5501 | 0/4000810 | read-write | primary | primary
node2 | 2 | localhost:5502 | 0/4000810 | read-only | secondary | secondary
node3 | 3 | localhost:5503 | 0/4000810 | none | maintenance | maintenance
bestie theConnectioncolumn literally saysnonefor node3 now β that's the maintenance era. iconic behavior. π
π AUTHOR π
Microsoft
π COPYRIGHT π
Copyright (c) Microsoft Corporation. All rights reserved.
and that's the whole page, periodt. π this was pg_auto_failover version 2.2, dated Apr 07, 2025 β catch you on the flip side, bestie, go forth and maintain responsibly πβ¨π
π¦ where this page comes from
- debian trixie: pg-auto-failover-cli 2.2-2 Β· PostgreSQL
- ubuntu questing: pg-auto-failover-cli 2.2-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms