Skip to content

Commit

Permalink
Merge pull request databendlabs#2553 from zhang2014/fix/ISSUE-2542
Browse files Browse the repository at this point in the history
ISSUE-2542 fix server hang when use wait in entrypoint
  • Loading branch information
sundy-li authored Oct 31, 2021
2 parents 71daf15 + e7ce9d1 commit 4d8c197
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions common/base/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ impl Runtime {
let mut runtime_builder = Self::tracker_builder(tracker.clone());
Self::create(tracker, runtime_builder.worker_threads(workers))
}

pub fn block_on<F: Future>(&self, future: F) -> F::Output {
self.handle.block_on(future)
}
}

impl TrySpawn for Runtime {
Expand Down
10 changes: 6 additions & 4 deletions common/macros/src/async_entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ fn parse_knobs(mut input: syn::ItemFn, is_test: bool, has_tracker: bool) -> Toke

let wait_in_future = match has_tracker {
true => quote::quote! {
let tracker = runtime.get_tracker();
main_impl(tracker.clone())
{
let tracker = runtime.get_tracker();
main_impl(tracker.clone())
}
},
false => quote::quote! { main_impl() },
};
Expand Down Expand Up @@ -110,9 +112,9 @@ fn parse_knobs(mut input: syn::ItemFn, is_test: bool, has_tracker: bool) -> Toke
#inner_impl

{
use common_base::BlockingWait;
let runtime = #rt;
#tail_return #wait_in_future.wait_in(&runtime, None).unwrap()#tail_semicolon
let wait_future = #wait_in_future;
#tail_return runtime.block_on(wait_future)#tail_semicolon
}
}
})
Expand Down
1 change: 1 addition & 0 deletions query/src/servers/mysql/mysql_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl Server for MySQLHandler {
if !graceful {
return;
}

self.abort_handle.abort();

if let Some(join_handle) = self.join_handle.take() {
Expand Down

0 comments on commit 4d8c197

Please sign in to comment.