Skip to content

Limitations

Some constraints come from transaction pooling; others belong to PG Proxy’s current implementation. Each section explains which applies. Check them alongside Features when deciding whether the proxy fits your application.

Transaction pooling shares PostgreSQL connections between clients. Session state does not follow a client between transactions, and long or idle transactions hold connections that other clients need. These constraints are shared with other transaction poolers.

PG Proxy also has specific boundaries around prepared statements and connection cleanup. See Transaction-pooling compatibility for supported SQL patterns, client options, and the state that can remain on a reused connection.

The dynamic reset mode can leak session state

Section titled “The dynamic reset mode can leak session state”

With reset_mode: dynamic, the proxy skips the release reset when the checkout’s SQL shows no sign of changing session state. A function or trigger can still change a setting, or the role, without the client’s SQL naming it. Unless PostgreSQL reports that setting with ParameterStatus, the change survives the skipped reset and reaches the next client of the connection. off never resets, so every change reaches the next client, apart from a role that application-supplied role management resets. The default, always, has neither gap. Run audit first to see which settings dynamic would leak on your traffic. See Reset modes.

When tracing is enabled, both Datadog and OpenTelemetry spans can contain raw SQL and error messages. The pg-proxy binary omits bind parameter values by default; -trace-parameters=true enables capture as db.parameters.N tags on sampled traces. Disabling capture does not remove SQL literals from db.statement or redact error messages. PG Proxy does not provide general telemetry redaction. See Telemetry configuration for binary and library options.

Client messages have no configured size limit

Section titled “Client messages have no configured size limit”

After authentication, PG Proxy does not limit the body size of client messages. (During authentication, the pg-proxy binary limits messages to 16 KiB; see fixed limits.) The protocol reader buffers the declared body before decoding it, so a sufficiently large message can exhaust proxy memory and interrupt other clients. The message-buffer setting controls flushing replies to clients; it does not limit incoming messages.

The datadog.pg_proxy.client_messages.body_length_bytes metric estimates size from decoded fields after a successful read. Some message decoders accept trailing padding without retaining it in those fields, so the metric can underreport the body that was buffered. It cannot enforce a memory limit or report a message that exhausts memory before decoding finishes. See Metrics and Go library configuration.

This applies when reads are routed to PostgreSQL replicas. With asynchronous replication, a replica can briefly lag behind the primary, so a read immediately after a write may not see that write. Traffic sent only to the PostgreSQL primary is unaffected by replica lag.

The scope includes routing enabled by the client’s pg_proxy.dynamic_routing option and routing enabled by configured read_clusters. It depends on whether the chosen destination is a replica, not just whether the client supplied the option. PG Proxy does not currently pin later transactions to the primary after a write. Reads that need to observe that write should use a destination configured to use the primary.

SQL classification guides routing; it does not enforce database permissions or read-only access. Once a transaction has acquired a backend connection, its statements stay on that connection.

See Read routing for the selection rules and fallback behavior.

Configuration changes and pool replacement

Section titled “Configuration changes and pool replacement”

The pg-proxy binary does not reload configuration. It reads its configuration file, credential files, and certificates once at startup. To apply changes, stop it with SIGTERM and start it again. Sessions drain at transaction boundaries for up to proxy.shutdown_grace_period; see Graceful shutdown. The proxy refuses new connections while it restarts; see Run in production for restarting without downtime. The binary does not handle SIGHUP: unlike PgBouncer, SIGHUP does not reload the configuration. It kills the process at once without draining sessions, unless SIGHUP was already ignored at launch, for example under nohup.

The rest of this section applies to applications that embed the library and refresh configuration with pkg/warden. When the configuration reconciler detects a changed cluster definition or a changed database used by that cluster, it recreates the cluster’s backend and closes the previous one. This can replace an entire pool even when only one backend setting changed.

The replacement is not warmed to its configured capacity before taking traffic. A successful connection check does not mean all pool connections are ready, so the first requests after a change may spend extra time opening connections. The reconciler also does not guarantee that the old backend remains available if replacement creation fails.

Changing a logical database’s main cluster has a separate effect: existing sessions are remapped, and a session holding a backend connection can have its active transaction aborted. Changing only the read_clusters mapping or weights affects future acquisitions without moving an active transaction. Replacing the underlying backend pools is still subject to the behavior above.

Plan main-cluster switches around a pause in application traffic and completion of active transactions. Watch connection errors and acquisition latency after configuration changes. See the configuration schema and Read routing.

Traffic mirroring can drop copies when queues are full, replay fails, or sessions close. Shadow replies are discarded, with no built-in comparison of source and shadow results. Copying and replay also consume resources, so mirroring does not guarantee unchanged latency or synchronized databases. See Traffic mirroring.

PG Proxy’s built-in SCRAM helper offers SCRAM-SHA-256, but not SCRAM-SHA-256-PLUS. Clients that require channel binding cannot authenticate through this helper. TLS connections are supported separately. See Authentication and TLS for how these pieces fit together.