imay commented on a change in pull request #718: Clean timeout tablets channel 
in TabletWriterMgr
URL: https://github.com/apache/incubator-doris/pull/718#discussion_r264171363
 
 

 ##########
 File path: be/src/runtime/tablet_writer_mgr.cpp
 ##########
 @@ -315,6 +324,45 @@ Status TabletWriterMgr::cancel(const 
PTabletWriterCancelRequest& params) {
     return Status::OK;
 }
 
+Status TabletWriterMgr::start_bg_worker() {
+    _tablets_channel_clean_thread = std::thread(
+        [this] {
+            #ifdef GOOGLE_PROFILER
+                ProfilerRegisterThread();
+            #endif
+
+            uint32_t interval = 60;
+            while (true) {
+                _start_tablets_channel_clean();
+                sleep(interval);
+            }
+        });
+    _tablets_channel_clean_thread.detach();
+    return Status::OK;
+}
+
+Status TabletWriterMgr::_start_tablets_channel_clean() {
+    const int32_t max_alive_time = 
config::streaming_load_rpc_max_alive_time_sec;
+    time_t now = time(nullptr);
+    {
+        std::lock_guard<std::mutex> l(_lock);
+        std::vector<TabletsChannelKey> need_delete_keys;
+
+        for (auto& kv : _tablets_channels) {
+            time_t last_updated_time = kv.second->last_updated_time();
+            if (difftime(now, last_updated_time) >= max_alive_time) {
+                need_delete_keys.emplace_back(kv.first);
+            }
+        }
+
+        for(auto key: need_delete_keys) {
 
 Review comment:
   ```suggestion
           for(auto& key: need_delete_keys) {
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to