Class: Privacy::DataDeletionWorker
- Inherits:
-
Object
- Object
- Privacy::DataDeletionWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/privacy/data_deletion_worker.rb
Overview
Sidekiq worker: scrubs a Privacy::DeletionRequest.
Instance Method Summary collapse
Instance Method Details
#perform(deletion_request_id) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/workers/privacy/data_deletion_worker.rb', line 39 def perform(deletion_request_id) # Atomic claim: a single UPDATE WHERE state = 'pending' moves the # row to `processing`. If two workers race, only one update affects # a row; the other returns early. Eliminates the duplicate-scrub / # duplicate-email window between `find_by` and `start_processing`. claimed_rows = Privacy::DeletionRequest .where(id: deletion_request_id, state: 'pending') .update_all(state: 'processing', updated_at: Time.current) # rubocop:disable Rails/SkipsModelValidations return if claimed_rows.zero? req = Privacy::DeletionRequest.find(deletion_request_id) Rails.logger.info("Privacy::DataDeletionWorker starting request=#{req.id} source=#{req.source}") run_scrub_for(req) rescue StandardError => e # Top-level safety net. With `retry: false`, any uncaught exception # would otherwise leave the request stuck in `processing` forever. handle_uncaught_exception(req, e) raise end |