EDB Postgres Distributed Proxy v5

EDB Postgres Distributed Proxy is a daemon that acts as an abstraction layer between the client application and Postgres. It interfaces with the PGD consensus mechanism to get the identity of the current write leader node and redirects traffic to that node.

The PGD cluster always has at least one global group and one data group. PGD elects the write leader for each data group that has the enable_proxy_routing and enable_raft options set to true. You can attach Proxy to a global group or data group. You can attach multiple proxies to each group.

PGD Proxy is a TCP layer 4 proxy.

How it works

Upon starting, PGD Proxy connects to one of the endpoints given in the local config file. It fetches:

  • DB connection information for all nodes
  • Proxy options like listen address, listen port
  • Routing details like current write leader

Endpoints given in the config file are used only at startup. After that, actual endpoints are taken from the PGD catalog's route_dsn field in bdr.node_routing_config_summary.

PGD manages write leader election. PGD Proxy interacts with PGD to get write leader change events notifications on Postgres notify/listen channels and routes client traffic to the current write leader. PGD Proxy disconnects all client connections on write leader change. Write leader election is a Raft-backed activity and is subject to Raft leader availability.

PGD Proxy responds to write leader change events that can be categorized into two modes of operation: failover and switchover.

Automatic transfer of write leadership from the current write leader node to a new node in the event of Postgres or operating system crash is called failover. PGD elects a new write leader when the current write leader goes down or becomes unresponsive. Once the new write leader is elected by PGD, proxy closes existing client connections to the old write leader and redirects new client connections to the newly elected write leader.

User-controlled, manual transfer of write leadership from the current write leader to a new target leader is called switchover. Switchover is triggered through the PGD CLI switchover command. The command is submitted to PGD, which attempts to elect the given target node as the new write leader. Similar to failover, PGD Proxy closes existing client connections and redirects new client connections to the newly elected write leader. This is useful during server maintenance, for example, if the current write leader node needs to be stopped for maintenance like a server update or OS patch update.

Managing PGD Proxy

PGD CLI provides a few commands to manage proxies in a PGD cluster, such as create-proxy, delete-proxy, set-proxy-options, and show-proxies. See PGD CLI for more information.

See Connection management for more information on the PGD side of configuration and management of PGD Proxy.

Proxy log location

syslog

  • Debian based - /var/log/syslog
  • Red Hat based - /var/log/messages

Use the journalctl command to filter and view logs for troubleshooting Proxy. The following are few sample commands for quick reference:

journalctl -u pgd-proxy -n100 -f
journalctl -u pgd-proxy --since today
journalctl -u pgd-proxy --since "10 min ago"
journalctl -u pgd-proxy --since "2022-10-20 16:21:50" --until "2022-10-20 16:21:55"