diff --git a/be/src/cloud/cloud_warm_up_manager.cpp b/be/src/cloud/cloud_warm_up_manager.cpp index c0d1462cbc3eab..bd661f46cb7837 100644 --- a/be/src/cloud/cloud_warm_up_manager.cpp +++ b/be/src/cloud/cloud_warm_up_manager.cpp @@ -178,7 +178,6 @@ void CloudWarmUpManager::handle_jobs() { if (_closed) break; if (!_pending_job_metas.empty()) { cur_job = _pending_job_metas.front(); - _pending_job_metas.pop_front(); } } @@ -276,6 +275,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