PG_AUTOCTL_DROP_NODE(1)
π pg_autoctl drop node π
okay bestie, welcome to the pg_autoctl drop node page from the pg_auto_failover manual (section 1, she's official β¨). this is the one where we yeet a node out of the picture. let's get into it π«Ά
β¨ NAME β¨
pg_autoctl drop node β literally just pg_autoctl drop node
pg_autoctl drop node β Drop a node from the pg_auto_failover monitor π
πΈ SYNOPSIS πΈ
this command drops a Postgres node from the pg_auto_failover monitor, no cap:
usage: pg_autoctl drop node [ [ [ --pgdata ] [ --destroy ] ] | [ --monitor [ [ --hostname --pgport ] | [ --formation --name ] ] ] ]
--pgdata path to data directory
--monitor pg_auto_failover Monitor Postgres URL
--formation pg_auto_failover formation
--name drop the node with the given node name
--hostname drop the node with given hostname and pgport
--pgport drop the node with given hostname and pgport
--destroy also destroy Postgres database
--force force dropping the node from the monitor
--wait how many seconds to wait, default to 60
π DESCRIPTION π
ok so pg_autoctl drop node has two modes of operations implemented in it. two moods. two vibes. pick your fighter π¦
When you're removing a node that still exists, you can use pg_autoctl drop node --destroy to remove the node both from the monitor and also delete the local Postgres instance entirely. full send, gone gone π
When you're removing a node that doesn't exist physically anymore, or when the VM that used to host the node has been lost entirely (rip bozo π), use either the pair of options --hostname and --pgport, or the pair of options --formation and --name, to match the node registration record on the monitor database β and get it removed from the known list of nodes on the monitor. it's giving detective work πβ¨
Then option --force can be used when the target node to remove does not exist anymore. When a node has been lost entirely, it's not going to be able to finish the procedure itself, and it is then possible to instruct the monitor of the situation. like, the node can't do its own paperwork, so you do it for it. main character energy fr fr π
β¨ 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. π--hostnameβ Hostname of the Postgres node to remove from the monitor. Use either--nameor--hostname --pgport, but not both.--pgportβ Port of the Postgres node to remove from the monitor. Use either--nameor--hostname --pgport, but not both.--nameβ Name of the node to remove from the monitor. Use either--nameor--hostname --pgport, but not both.--destroyβ By default thepg_autoctl drop monitorcommands does not remove the Postgres database for the monitor. When using--destroy, the Postgres installation is also deleted. ποΈβ¨--forceβ By default a node is expected to reach the assigned stateDROPPEDwhen it is removed from the monitor, and has the opportunity to implement clean-up actions. When the target node to remove is not available anymore, it is possible to use the option--forceto immediately remove the node from the monitor. no waiting around, periodt π--waitβ How many seconds to wait for the node to be dropped entirely. The command stops when the target node is not to be found on the monitor anymore, or when the timeout has elapsed, whichever comes first. The value0(zero) disables the timeout and disables waiting entirely, making the command async. β°
π ENVIRONMENT π
PGDATAβ Postgres directory location. Can be used instead of the--pgdataoption.PG_AUTOCTL_MONITORβ Postgres URI to connect to the monitor node, can be used instead of the--monitoroption.PG_AUTOCTL_NODE_NAMEβ Node name to register to the monitor, can be used instead of the--nameoption.PG_AUTOCTL_REPLICATION_QUORUMβ Can be used instead of the--replication-quorumoption.PG_AUTOCTL_CANDIDATE_PRIORITYβ Can be used instead of the--candidate-priorityoption.PG_CONFIGβ Can be set to the absolute path to thepg_configPostgres tool. This is mostly used in the context of building extensions, though it can be a useful way to select a Postgres version when several are installed on the same system.PATHβ Used the usual way mostly. Some entries that are searched in thePATHby thepg_autoctlcommand are expected to be found only once, to avoid mistakes with Postgres major versions.PGHOST,PGPORT,PGDATABASE,PGUSER,PGCONNECT_TIMEOUT, ... β See the Postgres docs about Environment Variables for details.TMPDIRβ Thepgcopydbcommand creates all its work files and directories in${TMPDIR}/pgcopydb, and defaults to/tmp/pgcopydb.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 π
here's what it actually looks like when you run it, bestie π
$ pg_autoctl drop node --destroy --pgdata ./node3
17:52:21 54201 INFO Reaching assigned state "secondary"
17:52:21 54201 INFO Removing node with name "node3" in formation "default" from the monitor
17:52:21 54201 WARN Postgres is not running and we are in state secondary
17:52:21 54201 WARN Failed to update the keeper's state from the local PostgreSQL instance, see above for details.
17:52:21 54201 INFO Calling node_active for node default/4/0 with current state: PostgreSQL is running is false, sync_state is "", latest WAL LSN is 0/0.
17:52:21 54201 INFO FSM transition to "dropped": This node is being dropped from the monitor
17:52:21 54201 INFO Transition complete: current state is now "dropped"
17:52:21 54201 INFO This node with id 4 in formation "default" and group 0 has been dropped from the monitor
17:52:21 54201 INFO Stopping PostgreSQL at "/Users/dim/dev/MS/pg_auto_failover/tmux/node3"
17:52:21 54201 INFO /Applications/Postgres.app/Contents/Versions/12/bin/pg_ctl --pgdata /Users/dim/dev/MS/pg_auto_failover/tmux/node3 --wait stop --mode fast
17:52:21 54201 INFO /Applications/Postgres.app/Contents/Versions/12/bin/pg_ctl status -D /Users/dim/dev/MS/pg_auto_failover/tmux/node3 [3]
17:52:21 54201 INFO pg_ctl: no server running
17:52:21 54201 INFO pg_ctl stop failed, but PostgreSQL is not running anyway
17:52:21 54201 INFO Removing "/Users/dim/dev/MS/pg_auto_failover/tmux/node3"
17:52:21 54201 INFO Removing "/Users/dim/dev/MS/pg_auto_failover/tmux/config/pg_autoctl/Users/dim/dev/MS/pg_auto_failover/tmux/node3/pg_autoctl.cfg"
π AUTHOR π
Microsoft
π COPYRIGHT π
Copyright (c) Microsoft Corporation. All rights reserved.
and that's the whole page babes πΈ this was pg_auto_failover version 2.1, dated Jan 18, 2025 β go forth and drop nodes responsibly, ily, mwah ππ«Ά
π¦ 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