feat(worker): add DB-backed path to ProcessingState#742
Open
thomasrockhu-codecov wants to merge 1 commit intomainfrom
Open
feat(worker): add DB-backed path to ProcessingState#742thomasrockhu-codecov wants to merge 1 commit intomainfrom
thomasrockhu-codecov wants to merge 1 commit intomainfrom
Conversation
3f76621 to
0fadde0
Compare
c5551ca to
1f86365
Compare
0fadde0 to
668d5ed
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #742 +/- ##
==========================================
- Coverage 92.25% 92.25% -0.01%
==========================================
Files 1304 1304
Lines 47923 47949 +26
Branches 1628 1628
==========================================
+ Hits 44210 44233 +23
- Misses 3404 3407 +3
Partials 309 309
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
668d5ed to
d514a42
Compare
This was referenced Mar 10, 2026
6ce1a54 to
9c656c6
Compare
e0b3bdf to
696d952
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Add an optional db_session parameter to ProcessingState. When provided, all methods use DB queries (Upload.state_id) instead of Redis sets. When omitted, behavior is unchanged (Redis path). DB-backed methods: - get_upload_numbers: COUNT by state_id (UPLOADED=processing, PROCESSED=processed) - mark_upload_as_processed: UPDATE state_id to PROCESSED - mark_uploads_as_merged: UPDATE state_id to MERGED - get_uploads_for_merging: SELECT WHERE state_id=PROCESSED LIMIT batch_size - mark_uploads_as_processing / clear_in_progress_uploads: no-op (DB path) No callers change in this PR -- this is a pure capability addition. Made-with: Cursor
696d952 to
3b30446
Compare
5 tasks
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
db_sessionparameter toProcessingState. When provided, all methods query/updateUpload.state_idin the database instead of using Redis sets.db_sessionis omitted, behavior is completely unchanged (Redis path).Stacked on #741.
DB-backed method behavior
get_upload_numbersstate_id(UPLOADED=processing, PROCESSED=processed)SCARDon Redis setsmark_upload_as_processedstate_idto PROCESSEDSMOVEbetween setsmark_uploads_as_mergedstate_idto MERGEDSREMfrom processed setget_uploads_for_mergingstate_id=PROCESSEDLIMIT 10SRANDMEMBERmark_uploads_as_processingSADDto processing setclear_in_progress_uploadsSREMfrom processing setTest plan
TestProcessingStateDBPathtest class covers all DB-backed methodsMade with Cursor
Note
Low Risk
Default behavior remains Redis-backed and no callers were changed; the main risk is correctness/performance of the newly added SQLAlchemy code path when it’s enabled later (upload state transitions and merge selection).
Overview
Adds an optional
db_sessiontoProcessingStateso upload processing/processed/merged tracking can be derived from and persisted to the DB (Upload.state_id) rather than Redis sets.When
db_sessionis provided,get_upload_numberscountsUPLOADED/PROCESSEDuploads for the commit,mark_upload_as_processedandmark_uploads_as_mergedupdate state in-place,get_uploads_for_mergingselectsPROCESSEDuploads (bounded byMERGE_BATCH_SIZE), andclear_in_progress_uploadsmarks still-UPLOADEDuploads asERROR; the Redis path remains unchanged. Tests add a new DB-backed lifecycle suite using factories to validate counts, transitions, batch sizing, and no-op behavior.Written by Cursor Bugbot for commit 3b30446. This will update automatically on new commits. Configure here.