PG_AUTOCTL_DISABLE_MAINTENANCE(1)

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

πŸ’… PG_AUTOCTL DISABLE MAINTENANCE πŸ’…

okay bestie, welcome to the pg_auto_failover corner of the manual β€” this one's all about pg_autoctl disable maintenance, aka the glow-up button that takes your node out of maintenance mode and back into the main character spotlight. πŸ¦‹


✨ NAME ✨

pg_autoctl disable maintenance β€” that's the whole thing, that's the command. It Disable Postgres maintenance mode on this node. periodt. πŸ‘‘


🌸 SYNOPSIS 🌸

so a pg_auto_failover setup can be put into a maintenance state, right? and while a Postgres node is chillin' in that state, it's still registered to the monitor, and the monitor knows it's unreliable until maintenance gets disabled. and here's the important part, bestie β€” a node in maintenance state is not a candidate for promotion. not it. not today. πŸ™…

the typical use case for maintenance state? operating system or Postgres reboots β€” like when you're applying security upgrades and you just need everybody to chill for a sec. πŸ”§

here's the usage line, copy it exactly:

usage: pg_autoctl disable maintenance  [ --pgdata --allow-failover ]

--pgdata      path to data directory

πŸŽ€ OPTIONS πŸŽ€

  • --pgdata β€” where the Postgres node you're managing locally actually lives. it defaults to the environment variable PGDATA. also β€” use --monitor to connect to a monitor from anywhere, rather than the monitor URI that a local Postgres node managed with pg_autoctl would use. πŸ’«
  • --formation β€” the target formation where you wanna disable the secondary feature. tell it where to go, babe. 🎯

πŸ¦‹ ENVIRONMENT πŸ¦‹

  • PGDATA β€” Postgres directory location. you can use this instead of the --pgdata option. slay, less typing. ✨
  • PG_AUTOCTL_MONITOR β€” Postgres URI to connect to the monitor node, and yeah you can use this 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 whole journey. first, peep the state before:

$ 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

see node3? sitting in maintenance, vibing, contributing nothing. iconic but useless. 😭

now we run the disable:

$ pg_autoctl disable maintenance --pgdata node3
12:06:37 47542 INFO  Listening monitor notifications about state changes in formation "default" and group 0
12:06:37 47542 INFO  Following table displays times when notifications are received
    Time |  Name |  Node |      Host:Port |       Current State |      Assigned State
---------+-------+-------+----------------+---------------------+--------------------
12:06:37 | node3 |     3 | localhost:5503 |         maintenance |          catchingup
12:06:37 | node3 |     3 | localhost:5503 |          catchingup |          catchingup
12:06:37 | node3 |     3 | localhost:5503 |          catchingup |           secondary
12:06:37 | node3 |     3 | localhost:5503 |           secondary |           secondary

look at that glow-up pipeline: maintenance β†’ catchingup β†’ catchingup β†’ secondary. she's healing. she's thriving. we love a redemption arc. πŸ’–

and the final state check:

$ pg_autoctl show state
 Name |  Node |      Host:Port |       LSN |   Connection |       Current State |      Assigned State
------+-------+----------------+-----------+--------------+---------------------+--------------------
node1 |     1 | localhost:5501 | 0/4000848 |   read-write |             primary |             primary
node2 |     2 | localhost:5502 | 0/4000848 |    read-only |           secondary |           secondary
node3 |     3 | localhost:5503 | 0/4000000 |    read-only |           secondary |           secondary

node3 is BACK, bestie. read-only, secondary, part of the team again. ate and left no crumbs. πŸ“


πŸ‘‘ AUTHOR πŸ‘‘

Microsoft


Copyright (c) Microsoft Corporation. All rights reserved.


lowkey reminder: a node in maintenance state is not a candidate for promotion and the monitor treats it as unreliable β€” so don't forget to disable it when you're done, fr fr. πŸ™ˆ

okay that's the whole page, sending you off with love from pg_auto_failover version 2.1, dated Jan 18, 2025. go disable some maintenance, you got this. mwah. πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from