Skip to main content

Health, Readiness, And Drain

This page describes the HTTP health listener that exists in the proxy today.

Readiness is primary-oriented: it becomes unavailable when the configured primary cannot be reached. A failed pooled backend is discarded immediately, so it is not returned to service while the probe reports the primary as unavailable.

Current HTTP Endpoints

Enable the listener with health_addr.

[health]
health_addr = "0.0.0.0:9091"
readiness_backend_check_interval_ms = 1000
readiness_timeout_ms = 5000
EndpointMethodStatusBodyMeaning
/healthzGET200liveThe process accepted the health request.
/readyzGET200readyThe proxy is accepting clients and the backend probe is ready.
/readyzGET503not_readyThe proxy is draining, not accepting clients, or backend probing failed.
/stateGET200JSONNon-secret health snapshot.

All other paths return 404 not_found. Non-GET requests are treated as unknown paths.

POST /drain and GET /drain are not implemented in the HTTP health server. Do not configure Kubernetes pre-stop hooks against /drain until the endpoint exists in the proxy.

Backend failures during a request follow the same conservative boundary as readiness. A read may be replayed once only when no backend response byte has reached the client. Writes, authentication failures, and responses that have started are never replayed. The latter cases discard the backend and return SQLSTATE 08006 when the client protocol is still safe to continue.

State Payload

GET /state returns:

{
"process": "live",
"ready": "ready",
"drain_state": "accepting",
"active_clients": 0,
"backend_health": "ready"
}

Fields:

FieldValuesNotes
processliveThe current server always reports process liveness as live while it can answer.
readyready, not_readyCombines drain acceptance and backend probe status.
drain_stateaccepting, draining, drainedComes from the in-process drain controller.
active_clientsintegerNumber of active client sessions known to the drain controller.
backend_healthready, not_ready, degraded, liveResult of the background backend connection probe.

Kubernetes Probes

Use readiness and liveness probes only:

readinessProbe:
httpGet:
path: /readyz
port: health
livenessProbe:
httpGet:
path: /healthz
port: health

Do not add a pre-stop HTTP hook yet. Current graceful shutdown starts from process signal handling, not an HTTP drain request.

Failure Modes

ConditionResult
Backend connection fails or times out/readyz returns 503 not_ready.
Health listener address is unsetNo HTTP health server is started.
Health listener bind failsProxy startup fails.
Request path is unknownHTTP 404 not_found.
Request method is not GETHTTP 404 not_found.

Operational Checks

curl -fsS http://127.0.0.1:9091/healthz
curl -fsS http://127.0.0.1:9091/readyz
curl -fsS http://127.0.0.1:9091/state