-
Notifications
You must be signed in to change notification settings - Fork 409
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 a bug that ExchangeReceiver can't be canceled #4436
Changes from all commits
c14a5e9
8430a86
431a8c6
5ee78b2
382b3b4
2335e40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,18 +311,34 @@ ExchangeReceiverBase<RPCContext>::ExchangeReceiverBase( | |
template <typename RPCContext> | ||
ExchangeReceiverBase<RPCContext>::~ExchangeReceiverBase() | ||
{ | ||
setState(ExchangeReceiverState::CLOSED); | ||
msg_channel.finish(); | ||
close(); | ||
thread_manager->wait(); | ||
} | ||
|
||
template <typename RPCContext> | ||
void ExchangeReceiverBase<RPCContext>::cancel() | ||
{ | ||
auto cur_state = getState(); | ||
if (cur_state == ExchangeReceiverState::CANCELED || cur_state == ExchangeReceiverState::CLOSED) | ||
{ | ||
return; | ||
} | ||
setState(ExchangeReceiverState::CANCELED); | ||
msg_channel.finish(); | ||
} | ||
|
||
template <typename RPCContext> | ||
void ExchangeReceiverBase<RPCContext>::close() | ||
{ | ||
auto cur_state = getState(); | ||
if (cur_state == ExchangeReceiverState::CANCELED || cur_state == ExchangeReceiverState::CLOSED) | ||
{ | ||
return; | ||
} | ||
Comment on lines
+334
to
+337
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this check should be moved into |
||
setState(ExchangeReceiverState::CLOSED); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's safe to call it multiple times since they are idempotent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But it's weird that you can change the status from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another annoying point is that ExchangeReceiver also has another ExchangeReceiverState::ERROR state. So any suggestion about state checking? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The current version of TiFlash may also suffer from the same problem. How about refining it in future? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check added. |
||
msg_channel.finish(); | ||
} | ||
Comment on lines
+332
to
+340
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems that those lines are almost similar to L321-327 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. refined in another pr, since my local repo is broken, see another PR #4441 |
||
|
||
template <typename RPCContext> | ||
void ExchangeReceiverBase<RPCContext>::setUpConnection() | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,6 +352,8 @@ void MPPTask::runImpl() | |
else | ||
{ | ||
context->getProcessList().sendCancelToQuery(context->getCurrentQueryId(), context->getClientInfo().current_user, true); | ||
if (dag_context) | ||
dag_context->cancelAllExchangeReceiver(); | ||
Comment on lines
+355
to
+356
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why before L357? is it better to write errors to the turnnel first? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refering to chat history in our |
||
writeErrToAllTunnels(err_msg); | ||
} | ||
LOG_FMT_INFO(log, "task ends, time cost is {} ms.", stopwatch.elapsedMilliseconds()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about local-reader?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain more? I didn't get it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does local-reader not need to close?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is
local-reader
?