Add celery_id DB tracking for privacy requests and request tasks#7531
Draft
Add celery_id DB tracking for privacy requests and request tasks#7531
Conversation
Store pre-generated Celery task IDs directly on PrivacyRequest and RequestTask models instead of in Redis cache. This makes task tracking durable across Redis restarts and enables reliable task cancellation. Changes: - Add celery_id column to privacyrequest and requesttask tables - Pre-generate and persist celery_id before dispatching Celery tasks - Add cancel_celery_tasks method for batch revocation - Add retry count tracking with configurable limits - Clean up unnecessary inline imports across source and test files Made-with: Cursor
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Made-with: Cursor
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.
Description Of Changes
Stores pre-generated Celery task IDs directly on
PrivacyRequestandRequestTaskmodels instead of in Redis cache. This makes task tracking durable across Redis restarts and enables reliable task cancellation via batchrevoke().Key changes:
celery_idcolumn toprivacyrequestandrequesttasktables via Alembic migrationcancel_celery_tasks()method onPrivacyRequestfor batch revocationget_request_task_celery_task_ids()helper methodcache_task_tracking_keywith durable DB persistenceprivacy_request_requeue_retry_countconfig_cancel_interrupted_tasks_and_error_privacy_request()for interrupted task cleanupCode Changes
src/fides/api/alembic/migrations/versions/xx_2026_02_28_1200_ce488ce97a31_add_celery_id_to_privacy_request_and_request_task.py- New migration addingcelery_idcolumn to both tablessrc/fides/api/models/privacy_request/privacy_request.py- Addcelery_idcolumn,cancel_celery_tasks(),get_request_task_celery_task_ids(), celery task cancellation incancel_processing()src/fides/api/models/privacy_request/request_task.py- Addcelery_idcolumnsrc/fides/api/task/execute_request_tasks.py- Pre-generate and persistcelery_idbefore dispatching; moveuuidto top-level importsrc/fides/service/privacy_request/privacy_request_service.py- Pre-generate and persistcelery_idfor privacy request tasks; moveuuidto top-level importsrc/fides/api/service/privacy_request/request_service.py- Add_cancel_interrupted_tasks_and_error_privacy_request(), retry count tracking in requeue flowtests/ops/models/privacy_request/test_privacy_request.py- Tests forcancel_celery_tasks,get_request_task_celery_task_ids, integration withcancel_processing; clean up inline importstests/ops/models/privacy_request/test_request_task.py- Tests forcelery_idcolumn onRequestTasktests/ops/service/privacy_request/test_request_service.py- Tests for_cancel_interrupted_tasks_and_error_privacy_request, retry count requeue handling; clean up inline importstests/ops/util/test_cache.py- Tests for retry count cache functions; consolidate inline imports to top-leveltests/task/test_requeue_interrupted_tasks.py- Tests for enhanced requeue with retry limits; clean up inline importsSteps to Confirm
celery_idcolumn exists on bothprivacyrequestandrequesttasktablescelery_idis populated on thePrivacyRequestrecord before the Celery task startscelery_idpopulatedcancel_celery_tasks()issues batch revokepytest --no-cov tests/ops/models/privacy_request/test_privacy_request.py::TestCancelCeleryTasks tests/ops/service/privacy_request/test_request_service.py::TestCancelInterruptedTasksAndErrorPrivacyRequest tests/task/test_requeue_interrupted_tasks.py::TestEnhancedRequeueInterruptedTasks tests/ops/util/test_cache.py::TestPrivacyRequestRetryCache -vPre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and worksMade with Cursor