Runbook: Relay Upgrade
Applies to: pg-tide relay binary (pg-tide run)
Scope: Rolling upgrade procedure for high-availability deployments with
multiple relay instances.
Overview
The pg-tide relay keeps durable source offsets in PostgreSQL. Pipeline ownership is coordinated via worker-held PostgreSQL advisory-lock sessions. The v0.51.0 rolling runtime window is explicitly bounded: v0.50.0 and v0.51.0 relays may mix, while v0.49.0 and earlier relays must stop before the extension crosses the supported floor-to-target migration chain.
Pre-Upgrade Checklist
- Read the CHANGELOG for the target version — note any new required configuration keys or deprecated flags.
- Back up the database (or confirm PITR is current).
- Confirm current relay health:
pg-tide status --postgres-url "$PG_TIDE_POSTGRES_URL" pg-tide doctor --postgres-url "$PG_TIDE_POSTGRES_URL" - Stop all pre-v0.50.0 relays before upgrading the extension.
Back up the database, then run:
Do not start an older relay after the migration. Start only a relay covered by the v0.50.0/v0.51.0 compatibility window after verification.ALTER EXTENSION pg_tide UPDATE;
v0.51.0 relay and extension window
Upgrade v0.50.0 relays to v0.51.0 first, then update the extension through PostgreSQL's packaged adjacent migration:
ALTER EXTENSION pg_tide UPDATE TO '0.51.0';
The v0.51.0 relay checks pg_extension.extversion before it creates a
coordinator or polls. It rejects versions outside its declared window with
PGTIDE_EXTENSION_VERSION_INCOMPATIBLE. There is no bypass flag.
If the relay must be rolled back, run the released v0.50.0 relay while leaving the v0.51.0 extension installed. Do not downgrade the extension for this procedure; use the backup/PITR runbook for the irreversible extension boundary.
v0.47.0 Stop-Upgrade-Start Procedure
- Disable or stop every v0.44.0 relay and verify its ownership sessions are gone.
- Back up PostgreSQL and apply the extension migration.
- Deploy v0.47.0 relays.
- Verify scoped offsets, ownership, health, and duplicate handling.
An in-flight batch whose sink succeeded before shutdown may be redelivered with the same stable identity. This is expected at-least-once transport behavior.
Rolling Upgrade Procedure (Kubernetes)
1. Update the Deployment Image Tag
kubectl set image deployment/pg-tide \
pg-tide=ghcr.io/trickle-labs/pg-tide:0.47.0
Or update image.tag in values.yaml and run helm upgrade:
helm upgrade pg-tide oci://ghcr.io/trickle-labs/helm/pg-tide \
--set image.tag=0.47.0 \
--reuse-values
2. Watch the Rollout
kubectl rollout status deployment/pg-tide
Kubernetes replaces pods one at a time (controlled by maxUnavailable and
maxSurge). As each old pod is terminated:
- PostgreSQL advisory locks held by the old pod are released automatically when the connection closes (within ~1 s of pod termination).
- The new pod's coordinator reconciles and reacquires the released pipelines.
- Messages may be re-delivered (at-least-once) for any batch that was in-flight at the time of the old pod's termination.
3. Verify Post-Upgrade
# All pods should be running the new version:
kubectl get pods -l app.kubernetes.io/name=pg-tide -o json \
| jq '.items[].spec.containers[].image'
# Pipeline ownership should be fully restored:
pg-tide status --postgres-url "$PG_TIDE_POSTGRES_URL"
Rolling Upgrade Procedure (Docker / Systemd)
For single-instance or manual deployments:
-
For versions before v0.47.0, do not start the new relay alongside the old one. Stop all old instances first, then deploy the new image.
docker run -d --name pg-tide-new \ -e PG_TIDE_POSTGRES_URL="$PG_TIDE_POSTGRES_URL" \ ghcr.io/trickle-labs/pg-tide:0.47.0 -
Verify the new relay is healthy and has acquired pipelines:
docker logs pg-tide-new | grep "acquired lock" pg-tide status --postgres-url "$PG_TIDE_POSTGRES_URL" -
Stop the old relay (graceful drain):
docker stop --time 60 pg-tide-oldThe
--time 60gives the old relay up to 60 seconds to finish in-flight batches before hard-stopping. -
Clean up:
docker rm pg-tide-old docker rename pg-tide-new pg-tide
Configuration Changes Between Versions
New Required Configuration Keys
Check the CHANGELOG for any new required keys. The relay will fail to start with a clear error message if a required key is missing.
Deprecated Flags
Deprecated flags continue to work until the next major version. A
WARN-level log entry is emitted at startup if a deprecated flag is present.
Environment Variable Changes
| Old (pre-0.17.0) | New | Notes |
|---|---|---|
PG_TIDE_RELAY_POSTGRES_URL | PG_TIDE_POSTGRES_URL | Old name no longer recognised |
| Pre-v0.17 legacy env var | PG_TIDE_POSTGRES_URL | See CHANGELOG v0.17.0 for details |
Rollback
If the new relay is unhealthy after the upgrade:
- Start the old relay binary (advisory locks auto-transfer back).
- Stop the new relay.
- Investigate logs from the new relay for the root cause.
Rollback across the v0.45.0 lock/offset contract is not automatic. Keep the database backup and follow the release-specific rollback procedure; do not run mixed relay versions against the migrated catalog.
HA Considerations
- Minimum two relay instances are recommended for production to ensure zero-downtime upgrades.
maxUnavailable: 0in the Kubernetes PodDisruptionBudget ensures at least one relay is always running during node drains.- The Helm chart defaults (
helm/pg-tide/values.yaml) setreplicaCount: 1by default; use at least two replicas for HA and enable a PodDisruptionBudget.