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

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


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new 1a4da2ba7bb [branch-1.2](bug) Fix exception-unsafe in aggregation node 
(#31253)
1a4da2ba7bb is described below

commit 1a4da2ba7bb2cb5ff4e4306371aa3177fddb8091
Author: xy720 <22125576+xy...@users.noreply.github.com>
AuthorDate: Thu Feb 22 16:17:41 2024 +0800

    [branch-1.2](bug) Fix exception-unsafe in aggregation node (#31253)
    
    cherry-pick #28483
---
 be/src/vec/exec/vaggregation_node.h | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/be/src/vec/exec/vaggregation_node.h 
b/be/src/vec/exec/vaggregation_node.h
index 39b5cbbe9ea..727435fd407 100644
--- a/be/src/vec/exec/vaggregation_node.h
+++ b/be/src/vec/exec/vaggregation_node.h
@@ -737,12 +737,26 @@ public:
 private:
     void _expand() {
         _index_in_sub_container = 0;
-        _current_keys = _arena_pool.alloc(_size_of_key * 
SUB_CONTAINER_CAPACITY);
-        _key_containers.emplace_back(_current_keys);
-
-        _current_agg_data = 
(AggregateDataPtr)_arena_pool.alloc(_size_of_aggregate_states *
-                                                                
SUB_CONTAINER_CAPACITY);
-        _value_containers.emplace_back(_current_agg_data);
+        _current_keys = nullptr;
+        _current_agg_data = nullptr;
+        try {
+            _current_keys = _arena_pool.alloc(_size_of_key * 
SUB_CONTAINER_CAPACITY);
+            _key_containers.emplace_back(_current_keys);
+
+            _current_agg_data = 
(AggregateDataPtr)_arena_pool.alloc(_size_of_aggregate_states *
+                                                                    
SUB_CONTAINER_CAPACITY);
+            _value_containers.emplace_back(_current_agg_data);
+        } catch (...) {
+            if (_current_keys) {
+                _key_containers.pop_back();
+                _current_keys = nullptr;
+            }
+            if (_current_agg_data) {
+                _value_containers.pop_back();
+                _current_agg_data = nullptr;
+            }
+            throw;
+        }
     }
 
 private:


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

Reply via email to