Fix promise lost in ClientSide AuthHandler#3902
Closed
hangc0276 wants to merge 1 commit intoapache:masterfrom
Closed
Fix promise lost in ClientSide AuthHandler#3902hangc0276 wants to merge 1 commit intoapache:masterfrom
hangc0276 wants to merge 1 commit intoapache:masterfrom
Conversation
wenbingshen
approved these changes
May 19, 2023
Member
wenbingshen
left a comment
There was a problem hiding this comment.
Nice Catch!
It doesn't seem very easy to add an AddEntry request before the auth handshake is complete, especially getting it into the waitingForAuth queue, and the auth request will also trigger the promise execution.
Contributor
Author
|
We need to add a unit test for this change, move to the next release |
Member
|
As dicussed in #4293 I think we can close this PR now. |
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
#3783 changed the AddEntry Request type from
BookieProtocol.AddRequesttoByteBuforByteBufList, leading to the AddEntry request being added intowaitingForAuthqueue in the client-side AuthHandlerbookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
Lines 787 to 791 in 0171a40
bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/AuthHandler.java
Lines 363 to 364 in 0171a40
For the requests in the
waitingForAuth, they will be polled out byAuthHandshakeCompleteCallback#operationComplete.bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/AuthHandler.java
Lines 426 to 436 in 0171a40
However, the
waitingForAuthqueue only stores the AddEntry request, and it ignores the related ChannelPromise. When polling requests from thewaitingForAuthqueue inAuthHandshakeCompleteCallback#operationComplete, those requests will be written and flushed into the Netty channel without passing any ChannelPromises, and Netty will usevoidPromiseby default.In a word, the AddEntry request side passed ChannelPromise will be replaced with
voidPromise, and the original promise will never be complete and the following operations won't execute.bookkeeper/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
Lines 1159 to 1169 in 0171a40
There are two impactions:
nettyOpLoggermetric won't updateaddEntryOutstandingcounter metric won't updateChanges
Store the ChannelPromise along with the request in the client-side AuthHandle and pass it to the Netty channel when polling out.