Skip to content

fix: add session.remove() and engine.dispose() to all DB retry paths#574

Merged
neoneye merged 1 commit intomainfrom
fix/session-cleanup-retry-paths
Apr 14, 2026
Merged

fix: add session.remove() and engine.dispose() to all DB retry paths#574
neoneye merged 1 commit intomainfrom
fix/session-cleanup-retry-paths

Conversation

@neoneye
Copy link
Copy Markdown
Member

@neoneye neoneye commented Apr 14, 2026

Summary

Follow-up to #573. The PGRES_TUPLES_OK error occurs not just in token_metrics_store but across all DB operations (update_task_progress_with_retry, update_task_state_with_retry, _update_failure_diagnostics).

  • These retry functions only called db.session.rollback() on error, reusing the same corrupted connection on every retry attempt — so all retries failed
  • Now each retry discards the session via db.session.remove() to get a fresh connection from the pool
  • On final retry exhaustion, db.engine.dispose() is called to purge any remaining corrupted connections

Test plan

  • Deploy and trigger iframe plan from mach-ai.com
  • Verify PGRES_TUPLES_OK errors are recovered from on retry (not all retries failing)
  • Verify regular plans still complete normally

🤖 Generated with Claude Code

update_task_state_with_retry, update_task_progress_with_retry, and
_update_failure_diagnostics only called db.session.rollback() on error,
reusing the same corrupted connection on every retry attempt. Now each
retry discards the session to get a fresh connection, and the pool is
disposed when all retries are exhausted.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@neoneye neoneye merged commit 069fc2d into main Apr 14, 2026
3 checks passed
@neoneye neoneye deleted the fix/session-cleanup-retry-paths branch April 14, 2026 18:11
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