[Metadata] Fix zk callback thread - #13809
Closed
nodece wants to merge 1 commit into
Closed
Conversation
HQebupt
approved these changes
Jan 18, 2022
This was referenced Jan 18, 2022
nodece
marked this pull request as draft
January 19, 2022 03:23
nodece
marked this pull request as ready for review
January 19, 2022 07:10
nodece
commented
Jan 19, 2022
nodece
commented
Jan 19, 2022
nodece
commented
Jan 19, 2022
merlimat
requested changes
Jan 19, 2022
merlimat
left a comment
Contributor
There was a problem hiding this comment.
I think we should rather fix this by switching in a different thread in the batch callback:
execute( () -> {
// Trigger all the futures in the batch
for (int i = 0; i < ops.size(); i++) {
OpResult opr = results.get(i);
MetadataOp op = ops.get(i);
switch (op.getType()) {
case PUT:
handlePutResult(op.asPut(), opr);
break;
case DELETE:
handleDeleteResult(op.asDelete(), opr);
break;
case GET:
handleGetResult(op.asGet(), opr);
break;
case GET_CHILDREN:
handleGetChildrenResult(op.asGetChildren(), opr);
break;
default:
op.getFuture().completeExceptionally(new MetadataStoreException(
"Operation type not supported in multi: " + op.getType()));
}
}
}
nodece
force-pushed
the
fix_zk_callback
branch
4 times, most recently
from
January 20, 2022 05:09
c54ca39 to
07cb395
Compare
Member
Author
|
/pulsarbot rerun-failure-checks |
Member
Author
|
/pulsarbot rerun-failure-checks |
1 similar comment
Member
Author
|
/pulsarbot rerun-failure-checks |
Jason918
reviewed
Jan 21, 2022
|
|
||
| return null; | ||
| }, executor); | ||
| }, listenerExecutor); |
Contributor
There was a problem hiding this comment.
Can you explains more about why this listenerExecutor is added?
Member
Author
There was a problem hiding this comment.
We need to use a single thread to notify listeners.
nodece
force-pushed
the
fix_zk_callback
branch
from
January 21, 2022 05:57
07cb395 to
ed99085
Compare
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
nodece
force-pushed
the
fix_zk_callback
branch
from
January 21, 2022 08:20
ed99085 to
8580374
Compare
nodece
marked this pull request as draft
January 21, 2022 08:35
Member
Author
|
The current solution looks a little violent, another way is to avoid using |
14 tasks
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.
Signed-off-by: Zixuan Liu nodeces@gmail.com
Fixes #13211
Motivation
When a method calls the zk metadata store API, this method will use zk callback thread to do some things, once use
CompletableFuture#get()orCompletableFuture#join()is used to get a value synchronously in this method, this will cause the zk callback thread into the wait state, when we call the zk metadata store API again, the zk doesn't call the callback because the zk callback is wait state. At the same time, the Pulsar will be shutdown because the session watcher cannot detect whether zk is working.The jstack log:
The Pulsar@2. 9.x has been affected, but I think we also need to cherry-pick this commit to Pulsar@2.8.x
Modifications
Executors.newScheduledThreadPoolinstead ofnewSingleThreadExecutoras the metadata store executorZKMetadataStore#batchOperation()callback thread, use the metadata store executor to execute the callbackDocumentation
Need to update docs?
no-need-doc