Skip to content

fix(storage): add connection resilience to PostgreSQL kvstore#5734

Open
derekhiggins wants to merge 1 commit intoogx-ai:mainfrom
derekhiggins:fix/postgres-kvstore-resilience
Open

fix(storage): add connection resilience to PostgreSQL kvstore#5734
derekhiggins wants to merge 1 commit intoogx-ai:mainfrom
derekhiggins:fix/postgres-kvstore-resilience

Conversation

@derekhiggins
Copy link
Copy Markdown
Contributor

Summary

  • Add retry-on-error logic to the PostgreSQL kvstore that catches InterfaceError/OperationalError, reconnects once, and retries the operation
  • Extract connection setup into _connect() so it can be reused by _reconnect()
  • Add integration test that restarts postgres mid-session to verify recovery
  • Add kvstore-related path triggers to the SqlStore CI workflow

Fixes: #5610

Test plan

  • New integration test test_kvstore_recovers_after_postgres_restart verifies:
    • Baseline set/get works before restart
    • Postgres container is restarted and confirmed ready
    • set/get works after restart (previously failed with InterfaceError: cursor already closed)
  • CI passes on fork: tested on Python 3.12 and 3.13

The PostgreSQL kvstore fails permanently after a database restart
because it holds a single connection/cursor with no reconnect logic.
Add retry-on-error that catches InterfaceError/OperationalError,
reconnects once, and retries the operation.

Fixes: ogx-ai#5610

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Derek Higgins <derekh@redhat.com>
@derekhiggins derekhiggins force-pushed the fix/postgres-kvstore-resilience branch from a07b29e to e3d5aea Compare May 6, 2026 14:32
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.

PostgreSQL kvstore lacks connection resilience - fails after database restart

2 participants