Skip to content

fix: watchdog DNS tolerance + pg_isready in wait-service - #4

Merged
Negashev merged 1 commit into
mainfrom
fix/watchdog-tolerance-pg-ready
Jul 29, 2026
Merged

Negashev merged 1 commit into
mainfrom
fix/watchdog-tolerance-pg-ready

Conversation

@Negashev

Copy link
Copy Markdown
Owner

Problem

Two issues found after PR #3 (retry-loop re-provisioning):

1. Watchdog too aggressive (false positive re-provisioning)

Watchdog checked nslookup every 10s and killed the tunnel on first DNS failure. But nslookup can transiently fail (CoreDNS restart, network blip, DNS cache miss) even when the upstream workflow is alive. This caused unnecessary re-provisioning — client didn't crash, but watchdog killed the tunnel and ordered a new DB.

Fix: Require 3 consecutive DNS failures before killing the tunnel (30s of continuous DNS failure = real deletion, not transient).

2. wait-service checks TCP port, not PostgreSQL readiness

wait-service used nc -z (TCP port check) — but PostgreSQL from snapshot needs WAL recovery time. TCP port 5432 opens before PostgreSQL accepts connections. Client connects, gets websocket: close 1005 for minutes until PostgreSQL is ready.

Fix: Use pg_isready (PostgreSQL-native readiness check) after TCP port is open. Changed image from alpine to postgres:17-alpine (has pg_isready).

Testing

  • Watchdog: 3 consecutive failures = 30s of continuous DNS failure before kill
  • pg_isready: waits for actual PostgreSQL readiness, not just TCP port
  • E2E: manual workflow deletion → auto-recovery with correct PostgreSQL readiness

…wait-service

Watchdog was too aggressive — single nslookup failure (transient CoreDNS
hiccup, network blip) triggered tunnel kill and unnecessary re-provisioning.
Now requires 3 consecutive DNS failures before killing the tunnel.

wait-service was checking only TCP port 5432 (nc -z), not PostgreSQL
readiness. PostgreSQL from snapshot needs WAL recovery time — TCP port
opens before PostgreSQL accepts connections. Now uses pg_isready to wait
for actual PostgreSQL readiness, not just TCP port.
@Negashev
Negashev merged commit 48d923e into main Jul 29, 2026
1 check passed
@Negashev
Negashev deleted the fix/watchdog-tolerance-pg-ready branch July 29, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant