Fix error "Cannot transition status via :start from :started" in BulkImports::PipelineBatchWorker
When BulkImports::PipelineBatchWorker is retried due to a network error when downloading the exported relation files, the worker tries to change the status of BulkImports::BatchTracker from started
to started
, which causes the error: Cannot transition status via :start from :started (Reason(s): Status cannot transition via "start")
. This error occurs because such a status transition is not allowed. Therefore, we should allow such transition or update the worker not to change the status to started
if the status is already started
.
Proposed solution
Allow the start event in BulkImports::BatchTracker to transit from started
to started
similar is done in BulkImports::Tracker.
Note
Allowing such a transition can cause duplicated records in case the worker is retried due to a Sidekiq restart and the pipeline has already started to import records. Having said that, this is less likely to occur on batched migrations since a small dataset is used so most of the time the worker will finish during the Sidekiq restart graceful period
The duplicated record issue will be fixed in #424954 (closed)