-
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
Conversation
Signed-off-by: bestwoody <[email protected]>
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
add a failpoint in |
Signed-off-by: bestwoody <[email protected]>
…ugfix_cancel_recv
Signed-off-by: bestwoody <[email protected]>
template <typename RPCContext> | ||
void ExchangeReceiverBase<RPCContext>::close() | ||
{ | ||
setState(ExchangeReceiverState::CLOSED); |
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.
Make sure close
and cancel
only work if the state is normal?
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
But it's weird that you can change the status from CLOSE
to CANCELLED
, and CANCELLED
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
But it's weird that you can change the status from
CLOSE
toCANCELLED
, andCANCELLED
toCLOSE
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 comment
The reason will be displayed to describe this comment to others. Learn more.
check added.
Signed-off-by: bestwoody <[email protected]>
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.
LGTM
if (cur_state == ExchangeReceiverState::CANCELED || cur_state == ExchangeReceiverState::CLOSED) | ||
{ | ||
return; | ||
} |
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.
this check should be moved into setState
and under protection of mu
.
@@ -241,6 +241,7 @@ class TiRemoteBlockInputStream : public IProfilingBlockInputStream | |||
virtual void readSuffix() override | |||
{ | |||
LOG_FMT_DEBUG(log, "finish read {} rows from remote", total_rows); | |||
remote_reader->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.
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 islocal-reader
?
{ | ||
auto cur_state = getState(); | ||
if (cur_state == ExchangeReceiverState::CANCELED || cur_state == ExchangeReceiverState::CLOSED) | ||
{ | ||
return; | ||
} | ||
setState(ExchangeReceiverState::CLOSED); | ||
msg_channel.finish(); | ||
} |
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.
it seems that those lines are almost similar to L321-327
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.
refined in another pr, since my local repo is broken, see another PR #4441
if (dag_context) | ||
dag_context->cancelAllExchangeReceiver(); |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Refering to chat history in our OOT group
, xufei has explained the reason. Receiver needs close first
Signed-off-by: bestwoody [email protected]
What problem does this PR solve?
Issue Number: close #4432
Problem Summary:
What is changed and how it works?
fix a bug that ExchangeReceiver can't be canceled
Check List
Tests
Side effects
Documentation
Release note