diff --git a/be/src/cloud/cloud_warm_up_manager.cpp b/be/src/cloud/cloud_warm_up_manager.cpp index f9a256d2b97e4a..57e0a9ad27568c 100644 --- a/be/src/cloud/cloud_warm_up_manager.cpp +++ b/be/src/cloud/cloud_warm_up_manager.cpp @@ -186,7 +186,6 @@ void CloudWarmUpManager::handle_jobs() { if (_closed) break; if (!_pending_job_metas.empty()) { cur_job = _pending_job_metas.front(); - _pending_job_metas.pop_front(); } } @@ -292,6 +291,13 @@ void CloudWarmUpManager::handle_jobs() { { std::unique_lock lock(_mtx); _finish_job.push_back(cur_job); + // _pending_job_metas may be cleared by a CLEAR_JOB request + // so we need to check it again. + if (!_pending_job_metas.empty()) { + // We can not call pop_front before the job is finished, + // because GET_CURRENT_JOB_STATE_AND_LEASE is relying on the pending job size. + _pending_job_metas.pop_front(); + } } } #endif