platoneko commented on code in PR #15832:
URL: https://github.com/apache/doris/pull/15832#discussion_r1066912780


##########
be/src/agent/task_worker_pool.cpp:
##########
@@ -1693,4 +1697,43 @@ void 
TaskWorkerPool::_storage_update_storage_policy_worker_thread_callback() {
     }
 }
 
+void TaskWorkerPool::_push_cooldown_conf_worker_thread_callback() {
+    while (_is_work) {
+        TAgentTaskRequest agent_task_req;
+        TPushCooldownConfReq push_cooldown_conf_req;
+        {
+            std::unique_lock<std::mutex> 
worker_thread_lock(_worker_thread_lock);
+            while (_is_work && _tasks.empty()) {
+                _worker_thread_condition_variable.wait(worker_thread_lock);
+            }
+            if (!_is_work) {
+                return;
+            }
+
+            agent_task_req = _tasks.front();
+            push_cooldown_conf_req = agent_task_req.push_cooldown_conf;
+            _tasks.pop_front();
+        }
+        int64_t tablet_id = push_cooldown_conf_req.tablet_id;
+        TabletSharedPtr tablet = 
StorageEngine::instance()->tablet_manager()->get_tablet(tablet_id);
+        if (tablet.get() == nullptr) {
+            std::stringstream ss;
+            ss << "failed to get tablet. tablet_id=" << tablet_id;
+            LOG(WARNING) << ss.str();
+            return;
+        }
+        if (push_cooldown_conf_req.cooldown_term > 
tablet->tablet_meta()->cooldown_term()) {
+            tablet->tablet_meta()->set_cooldown_replica_id(

Review Comment:
   Update `cooldown_term` and `cooldown_replica_id` MUST be an atomic operation.



##########
be/src/agent/task_worker_pool.cpp:
##########
@@ -1693,4 +1697,43 @@ void 
TaskWorkerPool::_storage_update_storage_policy_worker_thread_callback() {
     }
 }
 
+void TaskWorkerPool::_push_cooldown_conf_worker_thread_callback() {
+    while (_is_work) {
+        TAgentTaskRequest agent_task_req;
+        TPushCooldownConfReq push_cooldown_conf_req;
+        {
+            std::unique_lock<std::mutex> 
worker_thread_lock(_worker_thread_lock);
+            while (_is_work && _tasks.empty()) {
+                _worker_thread_condition_variable.wait(worker_thread_lock);
+            }
+            if (!_is_work) {
+                return;
+            }
+
+            agent_task_req = _tasks.front();
+            push_cooldown_conf_req = agent_task_req.push_cooldown_conf;
+            _tasks.pop_front();
+        }
+        int64_t tablet_id = push_cooldown_conf_req.tablet_id;
+        TabletSharedPtr tablet = 
StorageEngine::instance()->tablet_manager()->get_tablet(tablet_id);
+        if (tablet.get() == nullptr) {
+            std::stringstream ss;
+            ss << "failed to get tablet. tablet_id=" << tablet_id;
+            LOG(WARNING) << ss.str();
+            return;
+        }
+        if (push_cooldown_conf_req.cooldown_term > 
tablet->tablet_meta()->cooldown_term()) {

Review Comment:
   update `cooldown_term` and `cooldown_replica_id` MUST be an atomic 
operation. I suggest to implement a `void Tablet::update_cooldown_conf(int64_t 
cooldown_term, int64_t cooldown_replica_id)` function.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to