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

yiguolei pushed a commit to branch branch-1.1-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.1-lts by this push:
     new 7bdbe1b53e [branch-1.1-lts](memtracker) enable_cancel_query support 
old mem tracker #13092
7bdbe1b53e is described below

commit 7bdbe1b53e96c331122192ac472e93afb27c3f54
Author: Xinyi Zou <zouxiny...@gmail.com>
AuthorDate: Fri Sep 30 18:10:58 2022 +0800

    [branch-1.1-lts](memtracker) enable_cancel_query support old mem tracker 
#13092
---
 be/src/common/config.h           |  2 +-
 be/src/runtime/mem_tracker.h     | 12 ++++++------
 be/src/runtime/runtime_state.cpp |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/be/src/common/config.h b/be/src/common/config.h
index 2ea2eb10b2..8e91db663a 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -68,7 +68,7 @@ CONF_Int64(tc_max_total_thread_cache_bytes, "1073741824");
 // defaults to bytes if no unit is given"
 // must larger than 0. and if larger than physical memory size,
 // it will be set to physical memory size.
-CONF_String(mem_limit, "90%");
+CONF_String(mem_limit, "80%");
 
 // the port heartbeat service used
 CONF_Int32(heartbeat_service_port, "9050");
diff --git a/be/src/runtime/mem_tracker.h b/be/src/runtime/mem_tracker.h
index d3808cdddb..a8d7a7f146 100644
--- a/be/src/runtime/mem_tracker.h
+++ b/be/src/runtime/mem_tracker.h
@@ -173,7 +173,7 @@ public:
         // This is independent of the consumption value of the mem tracker, 
which counts the virtual memory
         // of the process malloc.
         // for fast, expect MemInfo::initialized() to be true.
-        if (PerfCounters::get_vm_rss() + bytes >= MemInfo::mem_limit()) {
+        if (PerfCounters::get_vm_rss() + bytes >= MemInfo::mem_limit() && 
config::enable_cancel_query) {
             return Status::MemoryLimitExceeded(fmt::format(
                     "{}: TryConsume failed, bytes={} process whole 
consumption={}  mem limit={}",
                     label_, bytes, MemInfo::current_mem(), 
MemInfo::mem_limit()));
@@ -186,7 +186,7 @@ public:
         for (i = all_trackers_.size() - 1; i >= 0; --i) {
             MemTracker* tracker = all_trackers_[i];
             const int64_t limit = tracker->GetLimit(mode);
-            if (limit < 0) {
+            if (limit < 0 || !config::enable_cancel_query) {
                 tracker->consumption_->add(bytes); // No limit at this tracker.
             } else {
                 // If TryConsume fails, we can try to GC, but we may need to 
try several times if
@@ -262,7 +262,7 @@ public:
     /// exceeded.
     bool AnyLimitExceeded(MemLimit mode) {
         for (const auto& tracker : limit_trackers_) {
-            if (tracker->LimitExceeded(mode)) {
+            if (tracker->LimitExceeded(mode) && config::enable_cancel_query) {
                 return true;
             }
         }
@@ -281,7 +281,7 @@ public:
     // Return limit exceeded tracker or null
     MemTracker* find_limit_exceeded_tracker() {
         for (const auto& tracker : limit_trackers_) {
-            if (tracker->limit_exceeded()) {
+            if (tracker->limit_exceeded() && config::enable_cancel_query) {
                 return tracker;
             }
         }
@@ -298,7 +298,7 @@ public:
     void RefreshConsumptionFromMetric();
 
     // TODO(yingchun): following functions are old style which have no 
MemLimit parameter
-    bool limit_exceeded() const { return limit_ >= 0 && limit_ < 
consumption(); }
+    bool limit_exceeded() const { return limit_ >= 0 && limit_ < consumption() 
&& config::enable_cancel_query; }
 
     int64_t limit() const { return limit_; }
     bool has_limit() const { return limit_ >= 0; }
@@ -396,7 +396,7 @@ public:
 
     static bool limit_exceeded(const std::vector<std::shared_ptr<MemTracker>>& 
trackers) {
         for (const auto& tracker : trackers) {
-            if (tracker->limit_exceeded()) {
+            if (tracker->limit_exceeded() && config::enable_cancel_query) {
                 // TODO: remove logging
                 LOG(WARNING) << "exceeded limit: limit=" << tracker->limit()
                              << " consumption=" << tracker->consumption();
diff --git a/be/src/runtime/runtime_state.cpp b/be/src/runtime/runtime_state.cpp
index 6040718a33..864564e18b 100644
--- a/be/src/runtime/runtime_state.cpp
+++ b/be/src/runtime/runtime_state.cpp
@@ -322,7 +322,7 @@ Status RuntimeState::set_mem_limit_exceeded(const 
std::string& msg) {
 Status RuntimeState::check_query_state(const std::string& msg) {
     // TODO: it would be nice if this also checked for cancellation, but doing 
so breaks
     // cases where we use Status::Cancelled("Cancelled") to indicate that the 
limit was reached.
-    RETURN_IF_LIMIT_EXCEEDED(this, msg);
+    if (config::enable_cancel_query) RETURN_IF_LIMIT_EXCEEDED(this, msg);
     return query_status();
 }
 


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

Reply via email to