Skip to content

feat(worker): remove dual-write, make ProcessingState DB-only#750

Merged
thomasrockhu-codecov merged 3 commits intotomhu/processing-state-db-allfrom
tomhu/processing-state-db-only
Mar 10, 2026
Merged

feat(worker): remove dual-write, make ProcessingState DB-only#750
thomasrockhu-codecov merged 3 commits intotomhu/processing-state-db-allfrom
tomhu/processing-state-db-only

Conversation

@thomasrockhu-codecov
Copy link
Contributor

@thomasrockhu-codecov thomasrockhu-codecov commented Mar 10, 2026

Summary

Stacked on #749. Removes all Redis usage from ProcessingState, making the DB the single source of truth for upload processing state.

  • db_session is now a required parameter. All Redis operations removed (sadd, srem, smove, scard, srandmember, expire). _redis_key(), PROCESSING_STATE_TTL, and get_redis_connection import deleted
  • mark_uploads_as_processing is now an explicit no-op — uploads start as UPLOADED, which get_upload_numbers() counts as "processing"
  • upload.py: db_session threaded through schedule_task_schedule_coverage_processing_task
  • processing.py: removed the redis_state workaround, reuses the DB-backed state instance for the safety-net trigger
  • clear_in_progress_uploads and the safety-net finisher trigger are wrapped in try/except — they run in error-recovery paths where the DB transaction may already be aborted
  • All Redis-only and Redis-mock unit tests removed; DB-backed tests retained

Test plan

  • Unit tests for DB-backed ProcessingState pass
  • Unit tests for upload task (schedule_task signature) pass
  • Unit tests for process_upload pass
  • Integration tests (test_full_upload, test_full_carryforward) pass

- Make db_session a required parameter on ProcessingState
- Remove all Redis operations (sadd, srem, smove, scard, srandmember)
- Remove PROCESSING_STATE_TTL, _redis_key(), get_redis_connection import
- mark_uploads_as_processing is now an explicit no-op (uploads already
  exist with state_id=UPLOADED which get_upload_numbers counts)
- Pass db_session through upload.py schedule_task chain
- Remove redis_state workaround in processing.py safety-net trigger,
  reuse the existing DB-backed state instance
- Remove all Redis-only and Redis-mock unit tests

Made-with: Cursor
This runs in a finally block where the DB transaction may already be
in a failed state. Wrap in try/except so it doesn't mask the original
error. The upload stays UPLOADED, which is safe.

Made-with: Cursor
The safety-net is best-effort: if the DB query or finisher dispatch
fails, the chord callback will still trigger the finisher normally.
Wrapping in try/except prevents test failures in environments where
the repos table is unavailable.

Made-with: Cursor
@sentry
Copy link
Contributor

sentry bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.21%. Comparing base (b1fb518) to head (fe130ab).
⚠️ Report is 4 commits behind head on tomhu/processing-state-db-all.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/worker/services/processing/state.py 87.50% 2 Missing ⚠️
Additional details and impacted files
@@                        Coverage Diff                        @@
##           tomhu/processing-state-db-all     #750      +/-   ##
=================================================================
- Coverage                          92.22%   92.21%   -0.02%     
=================================================================
  Files                               1304     1304              
  Lines                              47933    47908      -25     
  Branches                            1628     1628              
=================================================================
- Hits                               44206    44178      -28     
- Misses                              3418     3421       +3     
  Partials                             309      309              
Flag Coverage Δ
workerintegration 58.64% <83.33%> (+0.01%) ⬆️
workerunit 90.20% <75.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thomasrockhu-codecov thomasrockhu-codecov merged commit fe130ab into tomhu/processing-state-db-all Mar 10, 2026
33 checks passed
@thomasrockhu-codecov thomasrockhu-codecov deleted the tomhu/processing-state-db-only branch March 10, 2026 20:18
@codecov-notifications
Copy link

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/worker/services/processing/state.py 87.50% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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