Class: BulkImports::StaleImportWorker
- Inherits:
-
Object
- Object
- BulkImports::StaleImportWorker
- Includes:
- ApplicationWorker, CronjobQueue
- Defined in:
- app/workers/bulk_imports/stale_import_worker.rb
Constant Summary
Constants included from ApplicationWorker
ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT
Constants included from Gitlab::Loggable
Constants included from WorkerAttributes
WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY_PER_DB, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::LOAD_BALANCED_DATA_CONSISTENCIES, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES
Instance Method Summary collapse
- #bulk_import_scope ⇒ Object
- #entity_scope ⇒ Object
- #logger ⇒ Object
-
#perform ⇒ Object
Using Keyset pagination for scopes that involve timestamp indexes.
Methods included from Gitlab::Loggable
Methods included from Gitlab::SidekiqVersioning::Worker
Methods included from WorkerContext
Instance Method Details
#bulk_import_scope ⇒ Object
45 46 47 |
# File 'app/workers/bulk_imports/stale_import_worker.rb', line 45 def bulk_import_scope BulkImport.stale.order_by_updated_at_and_id(:asc) end |
#entity_scope ⇒ Object
49 50 51 |
# File 'app/workers/bulk_imports/stale_import_worker.rb', line 49 def entity_scope BulkImports::Entity.with_trackers.stale.order_by_updated_at_and_id(:asc) end |
#logger ⇒ Object
41 42 43 |
# File 'app/workers/bulk_imports/stale_import_worker.rb', line 41 def logger @logger ||= Logger.build end |
#perform ⇒ Object
Using Keyset pagination for scopes that involve timestamp indexes
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/workers/bulk_imports/stale_import_worker.rb', line 16 def perform Gitlab::Pagination::Keyset::Iterator.new(scope: bulk_import_scope).each_batch do |imports| imports.each do |import| logger.error(message: 'BulkImport stale', bulk_import_id: import.id) import.cleanup_stale end end Gitlab::Pagination::Keyset::Iterator.new(scope: entity_scope).each_batch do |entities| entities.each do |entity| ApplicationRecord.transaction do logger.with_entity(entity).error( message: 'BulkImports::Entity stale' ) entity.cleanup_stale entity.trackers.find_each do |tracker| tracker.cleanup_stale end end end end end |