This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 9bbe042bb53 [fix](cloud) fix core dump in 
CloudWarmUpManager::handle_jobs (#43262)
9bbe042bb53 is described below

commit 9bbe042bb53bdc7887702810bf244f2ac7e4846c
Author: zhengyu <freeman.zhang1...@gmail.com>
AuthorDate: Thu Nov 7 13:47:01 2024 +0800

    [fix](cloud) fix core dump in CloudWarmUpManager::handle_jobs (#43262)
    
    use smart pointer to control the lifespan of JobMeta to avoid nullptr
    
    Signed-off-by: freemandealer <freeman.zhang1...@gmail.com>
---
 be/src/cloud/cloud_warm_up_manager.cpp | 13 +++++++------
 be/src/cloud/cloud_warm_up_manager.h   |  4 ++--
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/be/src/cloud/cloud_warm_up_manager.cpp 
b/be/src/cloud/cloud_warm_up_manager.cpp
index 9ef4b055314..06d6df11dc4 100644
--- a/be/src/cloud/cloud_warm_up_manager.cpp
+++ b/be/src/cloud/cloud_warm_up_manager.cpp
@@ -63,14 +63,14 @@ void CloudWarmUpManager::handle_jobs() {
 #ifndef BE_TEST
     constexpr int WAIT_TIME_SECONDS = 600;
     while (true) {
-        JobMeta cur_job;
+        std::shared_ptr<JobMeta> cur_job = nullptr;
         {
             std::unique_lock lock(_mtx);
             _cond.wait(lock, [this]() { return _closed || 
!_pending_job_metas.empty(); });
             if (_closed) break;
-            cur_job = std::move(_pending_job_metas.front());
+            cur_job = _pending_job_metas.front();
         }
-        for (int64_t tablet_id : cur_job.tablet_ids) {
+        for (int64_t tablet_id : cur_job->tablet_ids) {
             if (_cur_job_id == 0) { // The job is canceled
                 break;
             }
@@ -171,7 +171,7 @@ void CloudWarmUpManager::handle_jobs() {
         }
         {
             std::unique_lock lock(_mtx);
-            _finish_job.push_back(std::move(cur_job));
+            _finish_job.push_back(cur_job);
             _pending_job_metas.pop_front();
         }
     }
@@ -228,8 +228,9 @@ Status CloudWarmUpManager::check_and_set_batch_id(int64_t 
job_id, int64_t batch_
 void CloudWarmUpManager::add_job(const std::vector<TJobMeta>& job_metas) {
     {
         std::lock_guard lock(_mtx);
-        std::for_each(job_metas.begin(), job_metas.end(),
-                      [this](const TJobMeta& meta) { 
_pending_job_metas.emplace_back(meta); });
+        std::for_each(job_metas.begin(), job_metas.end(), [this](const 
TJobMeta& meta) {
+            _pending_job_metas.emplace_back(std::make_shared<JobMeta>(meta));
+        });
     }
     _cond.notify_all();
 }
diff --git a/be/src/cloud/cloud_warm_up_manager.h 
b/be/src/cloud/cloud_warm_up_manager.h
index fd034b2c5bc..219dedc5806 100644
--- a/be/src/cloud/cloud_warm_up_manager.h
+++ b/be/src/cloud/cloud_warm_up_manager.h
@@ -74,8 +74,8 @@ private:
     std::condition_variable _cond;
     int64_t _cur_job_id {0};
     int64_t _cur_batch_id {-1};
-    std::deque<JobMeta> _pending_job_metas;
-    std::vector<JobMeta> _finish_job;
+    std::deque<std::shared_ptr<JobMeta>> _pending_job_metas;
+    std::vector<std::shared_ptr<JobMeta>> _finish_job;
     std::thread _download_thread;
     bool _closed {false};
     // the attribute for compile in ut


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to