You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/06/10 15:07:23 UTC

[GitHub] [incubator-doris] xinyiZzz opened a new pull request, #10072: [fix] (mem tracker) Fix some memory leaks, inaccurate statistics, core dump, deadlock bugs

xinyiZzz opened a new pull request, #10072:
URL: https://github.com/apache/incubator-doris/pull/10072

   # Proposed changes
   
   Issue Number: close #10006  #10071
   
   ## Problem Summary:
   
   1. When the load task is canceled, the `IndexChannel` and `NodeChannel` mem trackers cannot be released in time, causing memory leaks.
   
   2. Fix the inaccuracy of `LoadChannel` mem tracker limit, and rewrite the variable name of `mem limit` in `LoadChannel`.
   
   3. When repairing logout task mem tracker, phmap erase fails and causes core dump.
   
   4. When repairing add_child_tracker, the mem limit exceeds, it will cause deadlock when log_usage is called.
   
   5. Avoid frequent Log printing when thread mem tracker limit exceeds, which will affect readability and performance.
   
   6. Optimize some details of mem tracker display.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: (No】)
   2. Has unit tests been added: (No Need)
   3. Has document been added or modified: (No Need)
   4. Does it need to update dependencies: (No)
   5. Are there any changes that cannot be rolled back: (No)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [incubator-doris] xinyiZzz commented on a diff in pull request #10072: [fix] (mem tracker) Fix some memory leaks, inaccurate statistics, core dump, deadlock bugs

Posted by GitBox <gi...@apache.org>.
xinyiZzz commented on code in PR #10072:
URL: https://github.com/apache/incubator-doris/pull/10072#discussion_r895201550


##########
be/src/runtime/mem_tracker_task_pool.cpp:
##########
@@ -86,13 +92,22 @@ void MemTrackerTaskPool::logout_task_mem_tracker() {
             it->second->parent()->consume_local(-it->second->consumption(),
                                                 MemTracker::get_process_tracker().get());
             expired_tasks.emplace_back(it->first);
+        } else {
+            // Log limit exceeded query tracker.
+            if (it->second->limit_exceeded()) {
+                it->second->mem_limit_exceeded(
+                        nullptr,
+                        fmt::format("Task mem limit exceeded but no cancel, queryId:{}", it->first),
+                        0, Status::OK());
+            }
         }
     }
     for (auto tid : expired_tasks) {
         // This means that after all RuntimeState is destructed,
         // there are still task mem trackers that are get or register.
         // The only known case: after an load task ends all fragments on a BE,`tablet_writer_open` is still
         // called to create a channel, and the load task tracker will be re-registered in the channel open.
+        // https://github.com/apache/incubator-doris/issues/9905
         if (_task_mem_trackers[tid].use_count() == 1) {

Review Comment:
   yes it's a bug,
   fixed, thks~



-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [incubator-doris] morningman commented on pull request #10072: [fix] (mem tracker) Fix some memory leaks, inaccurate statistics, core dump, deadlock bugs

Posted by GitBox <gi...@apache.org>.
morningman commented on PR #10072:
URL: https://github.com/apache/incubator-doris/pull/10072#issuecomment-1153208983

   And need to rebase to make p0 happy


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [incubator-doris] github-actions[bot] commented on pull request #10072: [fix] (mem tracker) Fix some memory leaks, inaccurate statistics, core dump, deadlock bugs

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #10072:
URL: https://github.com/apache/incubator-doris/pull/10072#issuecomment-1153694169

   PR approved by at least one committer and no changes requested.


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [incubator-doris] github-actions[bot] commented on pull request #10072: [fix] (mem tracker) Fix some memory leaks, inaccurate statistics, core dump, deadlock bugs

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #10072:
URL: https://github.com/apache/incubator-doris/pull/10072#issuecomment-1153694235

   PR approved by anyone and no changes requested.


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [incubator-doris] morningman merged pull request #10072: [fix] (mem tracker) Fix some memory leaks, inaccurate statistics, core dump, deadlock bugs

Posted by GitBox <gi...@apache.org>.
morningman merged PR #10072:
URL: https://github.com/apache/incubator-doris/pull/10072


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [incubator-doris] xinyiZzz commented on a diff in pull request #10072: [fix] (mem tracker) Fix some memory leaks, inaccurate statistics, core dump, deadlock bugs

Posted by GitBox <gi...@apache.org>.
xinyiZzz commented on code in PR #10072:
URL: https://github.com/apache/incubator-doris/pull/10072#discussion_r895200511


##########
be/src/runtime/mem_tracker.cpp:
##########
@@ -124,14 +124,17 @@ std::shared_ptr<MemTracker> MemTracker::create_tracker_impl(
     std::string reset_label;
     MemTracker* task_parent_tracker = reset_parent->parent_task_mem_tracker();
     if (task_parent_tracker) {
-        reset_label = fmt::format("{}:{}", label, split(task_parent_tracker->label(), ":")[1]);
+        reset_label = fmt::format("{}&{}", label, split(task_parent_tracker->label(), "&")[1]);

Review Comment:
   Because `:` has many meanings as a separator in task mem tracker label, and `&` is only used to split out `queryId` or `loadID` or `tabletID`.
   
   The latest code replaces `&` with `#`, which seems a little nicer :)



-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [incubator-doris] xinyiZzz commented on pull request #10072: [fix] (mem tracker) Fix some memory leaks, inaccurate statistics, core dump, deadlock bugs

Posted by GitBox <gi...@apache.org>.
xinyiZzz commented on PR #10072:
URL: https://github.com/apache/incubator-doris/pull/10072#issuecomment-1153222269

   > And need to rebase to make p0 happy
   
   done


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [incubator-doris] morningman commented on a diff in pull request #10072: [fix] (mem tracker) Fix some memory leaks, inaccurate statistics, core dump, deadlock bugs

Posted by GitBox <gi...@apache.org>.
morningman commented on code in PR #10072:
URL: https://github.com/apache/incubator-doris/pull/10072#discussion_r895192681


##########
be/src/runtime/mem_tracker_task_pool.cpp:
##########
@@ -86,13 +92,22 @@ void MemTrackerTaskPool::logout_task_mem_tracker() {
             it->second->parent()->consume_local(-it->second->consumption(),
                                                 MemTracker::get_process_tracker().get());
             expired_tasks.emplace_back(it->first);
+        } else {
+            // Log limit exceeded query tracker.
+            if (it->second->limit_exceeded()) {
+                it->second->mem_limit_exceeded(
+                        nullptr,
+                        fmt::format("Task mem limit exceeded but no cancel, queryId:{}", it->first),
+                        0, Status::OK());
+            }
         }
     }
     for (auto tid : expired_tasks) {
         // This means that after all RuntimeState is destructed,
         // there are still task mem trackers that are get or register.
         // The only known case: after an load task ends all fragments on a BE,`tablet_writer_open` is still
         // called to create a channel, and the load task tracker will be re-registered in the channel open.
+        // https://github.com/apache/incubator-doris/issues/9905
         if (_task_mem_trackers[tid].use_count() == 1) {

Review Comment:
   `_task_mem_trackers[tid]` maybe nullptr here?
   Because you add a case `if (!it->second)` before.



##########
be/src/runtime/mem_tracker.cpp:
##########
@@ -124,14 +124,17 @@ std::shared_ptr<MemTracker> MemTracker::create_tracker_impl(
     std::string reset_label;
     MemTracker* task_parent_tracker = reset_parent->parent_task_mem_tracker();
     if (task_parent_tracker) {
-        reset_label = fmt::format("{}:{}", label, split(task_parent_tracker->label(), ":")[1]);
+        reset_label = fmt::format("{}&{}", label, split(task_parent_tracker->label(), "&")[1]);

Review Comment:
   Why change to `&`?



-- 
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-unsubscribe@doris.apache.org

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


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