Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(processor): try fix incorrect error message #8365

Merged
merged 2 commits into from
Oct 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions src/query/service/src/pipelines/executor/pipeline_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use common_base::base::ThreadJoinHandle;
use common_base::base::TrySpawn;
use common_exception::ErrorCode;
use common_exception::Result;
use common_exception::ABORT_QUERY;
use futures::future::select;
use futures_util::future::Either;
use parking_lot::Mutex;
Expand Down Expand Up @@ -144,7 +145,15 @@ impl PipelineExecutor {
}

pub fn finish(&self, cause: Option<ErrorCode>) {
*self.finished_error.lock() = cause;
if let Some(cause) = cause {
let mut finished_error = self.finished_error.lock();

// We only save the cause of the first error.
if finished_error.is_none() {
*finished_error = Some(cause);
}
}

self.global_tasks_queue.finish(self.workers_condvar.clone());
self.graph.interrupt_running_nodes();
self.finished_notify.notify_waiters();
Expand All @@ -162,18 +171,21 @@ impl PipelineExecutor {
let mut thread_join_handles = self.execute_threads(self.threads_num);

while let Some(join_handle) = thread_join_handles.pop() {
if let Err(error_code) = join_handle.join().flatten() {
let may_error = Some(error_code);
(self.on_finished_callback)(&may_error)?;
return Err(may_error.unwrap());
let thread_res = join_handle.join().flatten();

{
let finished_error_guard = self.finished_error.lock();
if let Some(error) = finished_error_guard.as_ref() {
let may_error = Some(error.clone());
drop(finished_error_guard);
(self.on_finished_callback)(&may_error)?;
return Err(may_error.unwrap());
}
}
}

{
let finished_error_guard = self.finished_error.lock();
if let Some(error) = finished_error_guard.as_ref() {
let may_error = Some(error.clone());
drop(finished_error_guard);
// We will ignore the abort query error, because returned by finished_error if abort query.
if matches!(&thread_res, Err(error) if error.code() != ABORT_QUERY) {
let may_error = Some(thread_res.unwrap_err());
(self.on_finished_callback)(&may_error)?;
return Err(may_error.unwrap());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use common_base::base::Thread;
use common_datablocks::DataBlock;
use common_exception::ErrorCode;
use common_exception::Result;
use common_exception::ABORT_QUERY;
use common_exception::ABORT_SESSION;
use parking_lot::Condvar;
use parking_lot::Mutex;

Expand Down Expand Up @@ -186,29 +184,16 @@ impl PipelinePullingExecutor {
continue;
}
Err(_disconnected) => {
let mut killed = false;

if !self.executor.is_finished() {
killed = true;
self.executor.finish(None);
}

self.state.wait_finish();

if self.state.is_catch_error() {
let error_code = self.state.get_catch_error();

// If the query is killed here, we should ignore the abort error.
// when executing `select * from xx limit xx`, if enough rows have been returned, we try to kill the query in here for finish query as soon as possible.
if killed
&& error_code.code() != ABORT_QUERY
&& error_code.code() != ABORT_SESSION
{
return Err(error_code);
}
match !self.state.is_catch_error() {
true => Ok(None),
false => Err(self.state.get_catch_error()),
}

Ok(None)
}
};
}
Expand Down