PG_AUTOCTL_ENABLE_MAINTENANCE(1)

πŸ“¦
version 2.1 Β· 2 versions
, in fedora 43, fedora 44

✨ 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 variable PGDATA. And heads up: use --monitor to connect to a monitor from anywhere, instead of the monitor URI used by a local Postgres node managed with pg_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 --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 πŸ—‚οΈ

⭐ 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 (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