pg_octopus
pg_octopus · Runs a background worker that periodically connects to configured PostgreSQL nodes and records their health status.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100441 | pg_octopus | pg_octopus | 0.1 | STAT | PostgreSQL | C |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
Usage
Sources:
pg_octopus is an experimental background worker that records whether it can establish a libpq connection to a list of PostgreSQL host/port pairs. It checks TCP/database login reachability only; it does not assess replication state, read/write readiness, lag, quorum, or application health.
Enable the Worker
The worker must be preloaded and PostgreSQL restarted. Its implementation connects to the local database named postgres, so create the extension and node table there:
health_status is 1 for reachable, 0 for unreachable after retries, and -1 before a result is known.
Configuration Index
pg_octopus.health_check_periodsets the round duration in milliseconds.pg_octopus.health_check_timeoutsets each connection timeout in milliseconds.pg_octopus.health_check_max_retrieslimits retries after the first attempt.pg_octopus.health_check_retry_delaysets the delay between attempts.pg_octopus.nodes_tablechanges the table name read and updated by the worker.
Keep the timeout plus all retry delays and timeouts below the period so rounds do not continuously overrun.
Operational Boundaries
Remote checks always target database postgres and do not put a user or password in the connection string; libpq defaults, the worker environment, and pg_hba.conf therefore determine authentication. A successful connection proves only that this path and credential set can log in. The worker also has BGW_NEVER_RESTART, so a crash leaves checks stopped until PostgreSQL restarts. The reviewed source is an old Citus demonstration and uses dynamically constructed SQL for the configured table and node values. Restrict writes to the nodes table, monitor the worker process and timestamp results externally, test reload behavior, and do not use health_status alone for automated failover.