Skip to content

Commit 04cf8ff

Browse files
committed
[fix](sort) fix coredump by uncaught exception
1 parent 6debbc3 commit 04cf8ff

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

be/src/vec/core/sort_cursor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ struct BlockSupplierSortCursorImpl : public MergeSortCursorImpl {
251251
} else if (!status.ok()) {
252252
// Currently, a known error status is emitted when sender
253253
// close recei
254-
throw std::runtime_error(status.msg());
254+
throw Exception(status.code(), status.msg());
255255
}
256256
return false;
257257
}

be/src/vec/runtime/vsorted_run_merger.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ VSortedRunMerger::VSortedRunMerger(const VExprContextSPtrs& ordering_expr,
4848
_batch_size(batch_size),
4949
_limit(limit),
5050
_offset(offset) {
51-
init_timers(profile);
51+
_init_timers(profile);
5252
}
5353

5454
VSortedRunMerger::VSortedRunMerger(const SortDescription& desc, const size_t batch_size,
@@ -60,10 +60,10 @@ VSortedRunMerger::VSortedRunMerger(const SortDescription& desc, const size_t bat
6060
_offset(offset),
6161
_get_next_timer(nullptr),
6262
_get_next_block_timer(nullptr) {
63-
init_timers(profile);
63+
_init_timers(profile);
6464
}
6565

66-
void VSortedRunMerger::init_timers(RuntimeProfile* profile) {
66+
void VSortedRunMerger::_init_timers(RuntimeProfile* profile) {
6767
_get_next_timer = ADD_TIMER(profile, "MergeGetNext");
6868
_get_next_block_timer = ADD_TIMER(profile, "MergeGetNextBlock");
6969
}
@@ -97,15 +97,15 @@ Status VSortedRunMerger::prepare(const vector<BlockSupplier>& input_runs) {
9797
return Status::OK();
9898
}
9999

100-
Status VSortedRunMerger::get_next(Block* output_block, bool* eos) {
100+
Status VSortedRunMerger::_get_next_internal(Block* output_block, bool* eos) {
101101
ScopedTimer<MonotonicStopWatch> timer(_get_next_timer);
102102
// Only have one receive data queue of data, no need to do merge and
103103
// copy the data of block.
104104
// return the data in receive data directly
105105

106106
if (_pending_cursor != nullptr) {
107107
MergeSortCursor cursor(_pending_cursor);
108-
if (has_next_block(cursor)) {
108+
if (_has_next_block(cursor)) {
109109
_priority_queue.push(cursor);
110110
}
111111
_pending_cursor = nullptr;
@@ -124,7 +124,7 @@ Status VSortedRunMerger::get_next(Block* output_block, bool* eos) {
124124
_priority_queue.pop();
125125
return Status::OK();
126126
}
127-
has_next_block(current);
127+
_has_next_block(current);
128128
} else {
129129
current->pos += _offset;
130130
_offset = 0;
@@ -139,7 +139,7 @@ Status VSortedRunMerger::get_next(Block* output_block, bool* eos) {
139139
_priority_queue.pop();
140140
return Status::OK();
141141
}
142-
*eos = !has_next_block(current);
142+
*eos = !_has_next_block(current);
143143
} else {
144144
*eos = true;
145145
}
@@ -156,7 +156,7 @@ Status VSortedRunMerger::get_next(Block* output_block, bool* eos) {
156156
_priority_queue.pop();
157157
return Status::OK();
158158
}
159-
*eos = !has_next_block(current);
159+
*eos = !_has_next_block(current);
160160
} else {
161161
*eos = true;
162162
}
@@ -190,7 +190,7 @@ Status VSortedRunMerger::get_next(Block* output_block, bool* eos) {
190190
}
191191

192192
// In pipeline engine, needs to check if the sender is readable before the next reading.
193-
if (!next_heap(current)) {
193+
if (!_next_heap(current)) {
194194
return Status::OK();
195195
}
196196

@@ -213,21 +213,25 @@ Status VSortedRunMerger::get_next(Block* output_block, bool* eos) {
213213
return Status::OK();
214214
}
215215

216-
bool VSortedRunMerger::next_heap(MergeSortCursor& current) {
216+
Status VSortedRunMerger::get_next(Block* output_block, bool* eos) {
217+
RETURN_IF_CATCH_EXCEPTION(return _get_next_internal(output_block, eos));
218+
}
219+
220+
bool VSortedRunMerger::_next_heap(MergeSortCursor& current) {
217221
if (!current->isLast()) {
218222
current->next();
219223
_priority_queue.push(current);
220224
} else if (_pipeline_engine_enabled) {
221225
// need to check sender is readable again before the next reading.
222226
_pending_cursor = current.impl;
223227
return false;
224-
} else if (has_next_block(current)) {
228+
} else if (_has_next_block(current)) {
225229
_priority_queue.push(current);
226230
}
227231
return true;
228232
}
229233

230-
inline bool VSortedRunMerger::has_next_block(doris::vectorized::MergeSortCursor& current) {
234+
inline bool VSortedRunMerger::_has_next_block(doris::vectorized::MergeSortCursor& current) {
231235
ScopedTimer<MonotonicStopWatch> timer(_get_next_block_timer);
232236
return current->has_next_block();
233237
}

be/src/vec/runtime/vsorted_run_merger.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@ class VSortedRunMerger {
9494
RuntimeProfile::Counter* _get_next_block_timer;
9595

9696
private:
97-
void init_timers(RuntimeProfile* profile);
97+
void _init_timers(RuntimeProfile* profile);
9898

9999
/// In pipeline engine, return false if need to read one more block from sender.
100-
bool next_heap(MergeSortCursor& current);
101-
bool has_next_block(MergeSortCursor& current);
100+
bool _next_heap(MergeSortCursor& current);
101+
bool _has_next_block(MergeSortCursor& current);
102+
103+
Status _get_next_internal(Block* output_block, bool* eos);
102104
};
103105

104106
} // namespace vectorized

0 commit comments

Comments
 (0)