fix: store_enrichment commits internally so external callers don't lose data#5
Open
gnujoow wants to merge 1 commit into
Open
fix: store_enrichment commits internally so external callers don't lose data#5gnujoow wants to merge 1 commit into
gnujoow wants to merge 1 commit into
Conversation
…lose data Each enrichment result costs a request against FreqBlog's monthly quota, so silently rolling it back when a caller forgets db.conn.commit() is data loss (observed: 146 stored via an external script, only 2 survived). store_enrichment now commits before returning. enrich_pending's batched COMMIT_EVERY/finally commits still cover the bump/mark paths and become harmless no-ops for the store path (WAL + synchronous=NORMAL keeps per-row commits cheap). Fixes #3 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Fixes #3.
Database.store_enrichment()wrote the enrichment row (and the status update) but never committed —enrich_pendingcommits in its own loop, so the CLI path was safe, but any external caller (e.g. a script loopingdb.store_enrichment(...)) silently lost everything on close. Since every enrichment result costs a request against FreqBlog's monthly quota (~1,000/month), a rollback here is unrecoverable data loss.Changes
store_enrichmentnow commits before returning (bothfinalize=Trueandfinalize=Falsepaths), with a docstring note explaining why.enrich_pendingis unchanged: itsCOMMIT_EVERY/finallycommits still cover thebump_enrich_attempt/mark_enrichment_failedpaths, and become harmless no-ops for the store path. WAL +synchronous=NORMALkeeps per-row commits cheap.Tests
Two regression tests using a file-backed DB: call
store_enrichmentwith no explicit commit, close (which rolls back any open transaction), reopen, and assert the enrichment row and track status survived — for both the finalized andfinalize=False(partial) paths.147 passed(baseline 145).🤖 Generated with Claude Code