fix(ingestion): retain generation id across failed flushes and rollback - #146
Merged
Merged
Conversation
… handler
AsyncSession.rollback() expires every loaded ORM object even with
expire_on_commit=False. The failure handler then read generation.id,
which needs a lazy refresh and fails in async code ("greenlet_spawn has
not been called"), so the error state was again never recorded and the
document kept a stale processing_attempt_id.
Capture the generation id before the rollback and skip marking the
generation failed when none was created.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Preserve the scalar identity before writes can expire ORM state. Cover fresh and existing generations and retain published content on reprocess failure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A failed SQLAlchemy flush can expire a generation before the failure handler starts. Reading generation.id in that handler could then raise before rollback and leave the document's processing attempt stuck.
Capture the scalar generation ID immediately after lookup or construction, before generation writes. Use that scalar after rollback, preserving the existing attempt ownership and published-content guards.
Validation: 33 targeted main/worker tests pass, including fresh/existing generation expiration before the handler and READY document preservation. Nine failure-handler tests pass on the exact older API source baseline. Ruff passes. Independent read-only review found no blocker or major issue. A local SQLite/SQLAlchemy check confirms expiration occurs during a failed flush, before explicit rollback. No production failure was injected and no schema/datastore changes are included.