WorkLockManager: Reconnect if we are on a read-only replica#3328
WorkLockManager: Reconnect if we are on a read-only replica#3328kensimon wants to merge 1 commit into
Conversation
Currently WorkLockManager health checks the connection by running db.ping(), but this will still appear successful even if we're connected to a read-only replica (which may happen if a failover occurs.) Improve the error handling to detect this and explicitly reconnect.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughWorkLockManager's connection handling was reworked to introduce a ReservedConnection wrapper that tracks an optional pooled PgConnection, checks health via transaction_read_only, and reacquires a fresh connection when unhealthy or read-only, replacing prior ping-based logic. Handlers and a new integration test were updated accordingly. ChangesReservedConnection health-check rework
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant RunLoop
participant ReservedConnection
participant PgPool
participant Postgres
RunLoop->>ReservedConnection: get_if_healthy()
ReservedConnection->>Postgres: transaction_read_only query
Postgres-->>ReservedConnection: health status
alt connection unhealthy or read-only
ReservedConnection->>ReservedConnection: close reserved connection
RunLoop->>ReservedConnection: reacquire(&pool)
ReservedConnection->>PgPool: acquire()
PgPool-->>ReservedConnection: new PoolConnection
ReservedConnection->>Postgres: transaction_read_only check
Postgres-->>ReservedConnection: health status
end
ReservedConnection-->>RunLoop: PgConnection reference
RunLoop->>Postgres: execute AcquireLock/ReleaseLock/KeepLockAlive
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🔍 Container Scan Summary
Per-CVE detail lives in the per-service |
Currently WorkLockManager health checks the connection by running db.ping(), but this will still appear successful even if we're connected to a read-only replica (which may happen if a failover occurs.) Improve the error handling to detect this and explicitly reconnect.
Related issues
nvbugs/6097302
Type of Change
Breaking Changes
Testing
Additional Notes