Skip to content

Fix DB session corruption crashing pipeline tasks#532

Merged
neoneye merged 1 commit intomainfrom
fix/db-session-resilience
Apr 5, 2026
Merged

Fix DB session corruption crashing pipeline tasks#532
neoneye merged 1 commit intomainfrom
fix/db-session-resilience

Conversation

@neoneye
Copy link
Copy Markdown
Member

@neoneye neoneye commented Apr 5, 2026

Summary

  • When token_metrics_store fails to commit, the corrupted DB session propagates to _handle_task_completion, which crashes the entire Luigi task — even though the LLM work already succeeded
  • Use db.session.remove() (stronger than close()) to fully discard corrupted scoped sessions
  • Increase DB retry attempts from 2 to 3
  • On final DB failure, log and continue instead of crashing the pipeline
  • Add db.session.remove() to token_metrics_store error handler to prevent session corruption from propagating

Test plan

  • Run a plan via MCP with luigi_workers=4 and verify no ExtractConstraintsTask crashes from DB errors
  • Verify progress updates still work normally when DB is healthy

🤖 Generated with Claude Code

When token_metrics_store fails to commit, the corrupted session state
propagates to _handle_task_completion, which fails to read the task
from the DB and crashes the Luigi task — even though the LLM work
already succeeded.

Changes:
- Use db.session.remove() instead of close()/expire_all() for
  stronger scoped session cleanup that fully discards corrupted state
- Increase retry attempts from 2 to 3 in _handle_task_completion
- On final DB failure, log error and continue pipeline instead of
  raising — the actual work already completed successfully
- Add db.session.remove() to token_metrics_store error handler to
  prevent corrupted session from poisoning subsequent operations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@neoneye neoneye merged commit df16e10 into main Apr 5, 2026
3 checks passed
@neoneye neoneye deleted the fix/db-session-resilience branch April 5, 2026 16:23
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