Repository navigation
[Fix][Client] Fixed cnx channel Inactive causing the request fail to time out and fail to return - #17051
Merged
codelipenghui merged 5 commits intoAug 18, 2022
Merged
[Fix][Client] Fixed cnx channel Inactive causing the request fail to time out and fail to return#17051codelipenghui merged 5 commits into
codelipenghui merged 5 commits into
Conversation
coderzc
approved these changes
Aug 14, 2022
…time out and fail to return ### Motivation There may be a concurrency problem between sendRequestAndHandleTimeout and channelInactive, which may cause the future to not be completed and cause the thread to get stuck. 1. channelInactive: 1.1 complete all futures in pendingRequests 1.2 and then clear the pendingRequests. 2. sendRequestAndHandleTimeout 2.1 put request into pending 2.2 write the requests into channel, if ailed, the listener will remove the request from pendingRequests. And complete exceptionally. If the execution order is 1.1 -> 2.1 -> 1.2 -> 2.2, then the corresponding future cannot be retrieved at 2.2. 2.1 The future put in will never be completed. ### Modification Delete pendingRequests.clear(), but all use remove to clear the request.
codelipenghui
approved these changes
Aug 16, 2022
codelipenghui
left a comment
Contributor
There was a problem hiding this comment.
LGTM, please also help check if there are other cases also need the same fix, such as lookup, tc handler, etc.
congbobo184
approved these changes
Aug 16, 2022
eolivelli
reviewed
Aug 16, 2022
eolivelli
left a comment
Contributor
There was a problem hiding this comment.
overall LGTM
but I have left a question
I am afraid we will see "ConcurrentModificationException"
can you please double check ?
Contributor
Author
TC handler has a check for the handler state. Nowhere else found anything like |
nicoloboschi
pushed a commit
to datastax/pulsar
that referenced
this pull request
Aug 22, 2022
…time out and fail to return (apache#17051) (cherry picked from commit 7913fe5) (cherry picked from commit 8b792c4)
This was referenced Aug 30, 2022
|
When will this fix get released? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
There may be a concurrency problem between sendRequestAndHandleTimeout and channelInactive, which may cause the future not to be completed and cause the thread to get stuck.
1.1 complete all futures in pendingRequests
1.2 and then clear the pendingRequests.
2.1 put a request into pending
2.2 write the requests into the channel, if ailed, the listener will remove the request from pendingRequests. And complete exceptionally.
If the execution order is 1.1 -> 2.1 -> 1.2 -> 2.2, then the corresponding future cannot be retrieved at 2.2. 2.1 The future put in will never be completed.
Modification
Delete pendingRequests.clear(), but all use remove to clear the request.
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation
Check the box below or label this PR directly.
Need to update docs?
doc-required(Your PR needs to update docs and you will update later)
doc-not-needed(Please explain why)
doc(Your PR contains doc changes)
doc-complete(Docs have been already added)