Fix data race in tunnel_set/receiver_set and establish call data (#5650) #5652
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an automated cherry-pick of #5650
What problem does this PR solve?
Issue Number: ref #5095, close #5651
Problem Summary:
In Some refinements of
mpp_exchange_receiver_map
andMPPTunnelSet
#5132, it try to use the atomic variablestatus
to protect tunnel_set/receiver_set in multiple thread read/write(MPPTask::runImpl thread to write and MPPTask::abort thread to read):tiflash/dbms/src/Flash/Mpp/MPPTask.cpp
Lines 145 to 147 in b6536f6
Unfortunately, it turns out not working becase the value of
status
can be changed after L145 and before L147tiflash/dbms/src/Flash/EstablishCall.cpp
Lines 106 to 113 in b6536f6
After
write(packet)
in L109, the call data is put back to completion queue, and it can be deleted anytime, so there is a chance that before executing L110, the call data itself has been deleted.What is changed and how it works?
write(packet)
, sincewrite(packet)
always return true, just seterr_status
toOK
beforewrite(packet)
Check List
Tests
run random failpoint tests
Side effects
Documentation
Release note