Skip to content

fix(ingestion): retain generation id across failed flushes and rollback - #146

Merged
yuzushi-dev merged 3 commits into
mainfrom
fix/ztd2048-failure-handler-expired
Oct 2, 2026
Merged

yuzushi-dev merged 3 commits into
mainfrom
fix/ztd2048-failure-handler-expired

Conversation

@yuzushi-dev

@yuzushi-dev yuzushi-dev commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

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.

… 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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T09:40:13.413536Z 59d806f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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.
@yuzushi-dev yuzushi-dev changed the title fix(ingestion): read generation id before rolling back in the failure handler fix(ingestion): retain generation id across failed flushes and rollback Oct 2, 2026
@yuzushi-dev
yuzushi-dev merged commit 760dfac into main Oct 2, 2026
5 checks passed
@yuzushi-dev
yuzushi-dev deleted the fix/ztd2048-failure-handler-expired branch October 2, 2026 09:39
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