yiguolei commented on code in PR #18503:
URL: https://github.com/apache/doris/pull/18503#discussion_r1168068536


##########
be/src/runtime/thread_context.h:
##########
@@ -312,33 +312,22 @@ class StopCheckThreadMemTrackerLimit {
     tracker->transfer_to(                               \
             size, 
doris::thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker_raw())
 
-// Consider catching other memory errors, such as memset failure, etc.
-#define RETURN_IF_CATCH_BAD_ALLOC(stmt)                                        
                    \
-    do {                                                                       
                    \
-        
doris::thread_context()->thread_mem_tracker_mgr->clear_exceed_mem_limit_msg();  
           \
-        if (doris::enable_thread_catch_bad_alloc) {                            
                    \
-            try {                                                              
                    \
-                { stmt; }                                                      
                    \
-            } catch (std::bad_alloc const& e) {                                
                    \
-                
doris::thread_context()->thread_mem_tracker()->print_log_usage(                 
   \
-                        
doris::thread_context()->thread_mem_tracker_mgr->exceed_mem_limit_msg());  \
-                return Status::MemoryLimitExceeded(fmt::format(                
                    \
-                        "PreCatch {}, {}", e.what(),                           
                    \
-                        
doris::thread_context()->thread_mem_tracker_mgr->exceed_mem_limit_msg())); \
-            }                                                                  
                    \
-        } else {                                                               
                    \
-            try {                                                              
                    \
-                doris::enable_thread_catch_bad_alloc = true;                   
                    \
-                Defer defer {[&]() { doris::enable_thread_catch_bad_alloc = 
false; }};             \
-                { stmt; }                                                      
                    \
-            } catch (std::bad_alloc const& e) {                                
                    \
-                
doris::thread_context()->thread_mem_tracker()->print_log_usage(                 
   \
-                        
doris::thread_context()->thread_mem_tracker_mgr->exceed_mem_limit_msg());  \
-                return Status::MemoryLimitExceeded(fmt::format(                
                    \
-                        "PreCatch {}, {}", e.what(),                           
                    \
-                        
doris::thread_context()->thread_mem_tracker_mgr->exceed_mem_limit_msg())); \
-            }                                                                  
                    \
-        }                                                                      
                    \
+#define RETURN_IF_CATCH_EXCEPTION(stmt)                                        
                \
+    do {                                                                       
                \
+        try {                                                                  
                \
+            
doris::thread_context()->thread_mem_tracker_mgr->clear_exceed_mem_limit_msg();  
   \
+            doris::enable_thread_catch_bad_alloc++;                            
                \
+            Defer defer {[&]() { doris::enable_thread_catch_bad_alloc--; }};   
                \

Review Comment:
   why do we need such variable "enable_thread_catch_bad_alloc" ?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to