PG_AUTOCTL SET NODE CANDIDATE-PRIORITY(1)

πŸ’– pg_autoctl set node candidate-priority β€” a manual, but make it bestie πŸ’–

okay so this is page PG_AUTOCTL SET NODE CANDIDATE-PRIORITY(1) from the pg_auto_failover manual, and honestly? it's giving "tiny command, big responsibility". buckle up, we're setting a node's candidate priority and the monitor is gonna hear about it. πŸŽ€


✨ NAME ✨

pg_autoctl set node candidate-priority β€” literally just that. the name is the name, bestie, no notes.

pg_autoctl set candidate-priority β€” same energy, set the candidate-priority property from the monitor. πŸ‘‘


🌸 SYNOPSIS 🌸

this command sets the pg_autoctl candidate priority for a given node:

usage: pg_autoctl set node candidate-priority  [ --pgdata ] [ --json ] [ --formation ] [ --name ] <priority: 0..100>

--pgdata      path to data directory
--formation   pg_auto_failover formation
--name        pg_auto_failover node name
--json        output data in the JSON format

so you're passing a <priority: 0..100> β€” that's the range, no going rogue with 9000, the vibes have limits. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

see also pg_autoctl show settings for the full list of replication settings. that's the lore drop if you want the whole picture, iykyk. πŸ“š


πŸ’… OPTIONS πŸ’…

  • --pgdata β€” where the Postgres node you're managing locally keeps its data. it defaults to the environment variable PGDATA. and hey, use --monitor if you wanna connect to a monitor from literally anywhere, instead of the monitor URI that a local Postgres node managed with pg_autoctl is using. 🌍
  • --json β€” output JSON formatted data. machine-readable, chef's kiss. πŸ€–
  • --formation β€” show replication settings for a given formation. defaults to default. πŸ—‚οΈ
  • --name β€” show replication settings for a given node, selected by name. say its name, respectfully. 🫢

🌈 ENVIRONMENT 🌈

  • PGDATA β€” Postgres directory location. can be used 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 πŸ”₯

setting it to 65 for node1, and look at the monitor doing the absolute most:

$ pg_autoctl set node candidate-priority --name node1 65
12:47:59 92326 INFO  Waiting for the settings to have been applied to the monitor and primary node
12:47:59 92326 INFO  New state is reported by node 1 "node1" (localhost:5501): "apply_settings"
12:47:59 92326 INFO  Setting goal state of node 1 "node1" (localhost:5501) to primary after it applied replication properties change.
12:47:59 92326 INFO  New state is reported by node 1 "node1" (localhost:5501): "primary"
65

and same thing but 50 and --json, because we love structured data in this house:

$ pg_autoctl set node candidate-priority --name node1 50 --json
12:48:05 92450 INFO  Waiting for the settings to have been applied to the monitor and primary node
12:48:05 92450 INFO  New state is reported by node 1 "node1" (localhost:5501): "apply_settings"
12:48:05 92450 INFO  Setting goal state of node 1 "node1" (localhost:5501) to primary after it applied replication properties change.
12:48:05 92450 INFO  New state is reported by node 1 "node1" (localhost:5501): "primary"
{
    "candidate-priority": 50
}

πŸ‘‘ AUTHOR πŸ‘‘

Microsoft


Copyright (c) Microsoft Corporation. All rights reserved.


okay that's the whole page, you ate. this was version 2.2, dated Apr 07, 2025, and yes the header and footer both spell it PG_AUTOCTL S...ATE-PRIORITY(1) because the terminal was being dramatic about column width. slay, go set some priorities. πŸ«ΆπŸ’–βœ¨

πŸ“¦ where this page comes from