diff --git a/src/replica/bulk_load/replica_bulk_loader.cpp b/src/replica/bulk_load/replica_bulk_loader.cpp index 0c1737ad93..aa044dd5fe 100644 --- a/src/replica/bulk_load/replica_bulk_loader.cpp +++ b/src/replica/bulk_load/replica_bulk_loader.cpp @@ -593,9 +593,14 @@ error_code replica_bulk_loader::remove_local_bulk_load_dir(const std::string &bu void replica_bulk_loader::cleanup_download_task() { for (auto &kv : _download_task) { - CLEANUP_TASK_ALWAYS(kv.second) + if (kv.second != nullptr) { + bool finished = false; + kv.second->cancel(false, &finished); + if (finished) { + kv.second = nullptr; + } + } } - _download_task.clear(); } // ThreadPool: THREAD_POOL_REPLICATION @@ -606,6 +611,7 @@ void replica_bulk_loader::clear_bulk_load_states() } cleanup_download_task(); + _download_task.clear(); _metadata.files.clear(); _metadata.file_total_size = 0; _cur_downloaded_size.store(0);