bgw_replstatus
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
bgw_replstatus | 1.0.8 | STAT | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 6510 | bgw_replstatus | No | Yes | Yes | No | No | No | - |
| Related | pgautofailover pglogical pg_failover_slots pgpool_recovery pgsentinel pglogical_origin repmgr pg_jobmon |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 1.0.8 | 1817161514 | bgw_replstatus | - |
| RPM | PGDG | 1.0.8 | 1817161514 | bgw_replstatus_$v | - |
| DEB | PGDG | 1.0.8 | 1817161514 | postgresql-$v-bgw-replstatus | - |
Install
You can install bgw_replstatus directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install bgw_replstatus; # Install for current active PG version
pig ext install -y bgw_replstatus -v 18 # PG 18
pig ext install -y bgw_replstatus -v 17 # PG 17
pig ext install -y bgw_replstatus -v 16 # PG 16
pig ext install -y bgw_replstatus -v 15 # PG 15
pig ext install -y bgw_replstatus -v 14 # PG 14
dnf install -y bgw_replstatus_18 # PG 18
dnf install -y bgw_replstatus_17 # PG 17
dnf install -y bgw_replstatus_16 # PG 16
dnf install -y bgw_replstatus_15 # PG 15
dnf install -y bgw_replstatus_14 # PG 14
apt install -y postgresql-18-bgw-replstatus # PG 18
apt install -y postgresql-17-bgw-replstatus # PG 17
apt install -y postgresql-16-bgw-replstatus # PG 16
apt install -y postgresql-15-bgw-replstatus # PG 15
apt install -y postgresql-14-bgw-replstatus # PG 14
Preload:
shared_preload_libraries = 'bgw_replstatus';
Usage
bgw_replstatus: lightweight replication status checker for load balancers
bgw_replstatus is a background worker that listens on a TCP port and immediately reports whether the node is a MASTER or STANDBY. Designed for load balancer health checks without requiring a full PostgreSQL connection.
How It Works
Any TCP connection to the configured port receives an immediate text response (MASTER or STANDBY) and the connection is closed. No request is needed.
Quick Test
nc localhost 5400
# Output: MASTER (or STANDBY)
HAProxy Configuration Example
frontend test
bind 127.0.0.1:5999
default_backend pgcluster
backend pgcluster
mode tcp
option tcp-check
tcp-check expect string MASTER
server s1 127.0.0.1:5500 check port 5400
server s2 127.0.0.1:5501 check port 5401 backup
server s3 127.0.0.1:5502 check port 5402 backup
Configuration
| Parameter | Default | Description |
|---|---|---|
bgw_replstatus.port | 5400 | TCP port to listen on |
bgw_replstatus.bind | (wildcard) | IP address to bind to |
Security note: There is no source verification. Protect the port with a host firewall.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.