PG_AUTOCTL_ENABLE_MAINTENANCE(1)
β¨ NAME β¨
pg_autoctl enable maintenance β okay bestie, this is the command that flips on Postgres maintenance mode on this node π
It's part of the pg_auto_failover toolset, and yes it's giving "I'm stepping out for a sec, don't promote me" energy.
πΈ SYNOPSIS πΈ
So here's the vibe: a pg_auto_failover node can be put into a maintenance state. When it is, the Postgres node is still registered to the monitor, and it's known to be unreliable until maintenance gets disabled. And a node sitting in maintenance state is not a candidate for promotion β no cap, it's out of the running.
When would you even use this? Classic: Operating System or Postgres reboot β like when you're applying security upgrades and need everyone to chill π§ββοΈ
usage: pg_autoctl enable maintenance [ --pgdata --allow-failover ]
--pgdata path to data directory
π OPTIONS π
--pgdataβ Where the Postgres node you're managing locally lives. Defaults to the environment variablePGDATA. And heads up: use--monitorto connect to a monitor from anywhere, instead of the monitor URI used by a local Postgres node managed withpg_autoctlβ¨--formationβ The target formation where you want to 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 this is the fun part, watch the glow-up happen in real time π
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
Then we put node3 into maintenance:
$ 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 look at it now β node3 is living its maintenance era πβ¨
$ 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
π AUTHOR π
Microsoft
π«Ά COPYRIGHT π«Ά
Copyright (c) Microsoft Corporation. All rights reserved.
That's the whole page, bestie β pg_auto_failover version 2.1, dated Jan 18, 2025, from the PG_AUTOCTL_ENABLE_MAINTENANCE(1) manual. Go forth and maintain πβ¨
π¦ 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