Repository navigation
[fix][flaky-test] Fix ClassCastException: BrokerService cannot be cast to class PulsarResources - #16821
Merged
Conversation
…t to class PulsarResources
Member
|
@poorbarcode The same problem is happening here, can you take a look at it together? #16666 |
Contributor
Author
shibd
reviewed
Jul 27, 2022
shibd
approved these changes
Jul 27, 2022
shibd
left a comment
Member
There was a problem hiding this comment.
Nice catch! I tested it locally and it can work.
Contributor
Author
Thanks. |
shibd
reviewed
Jul 27, 2022
coderzc
approved these changes
Jul 27, 2022
1 of 4 tasks
Technoboy-
reviewed
Jul 27, 2022
Technoboy-
approved these changes
Jul 27, 2022
codelipenghui
approved these changes
Jul 27, 2022
Contributor
Author
|
/pulsarbot rerun-failure-checks |
Closed
Member
|
It looks like Mockito's bug, but I'm still not sure how Mockito causes these things. So, I'll try to find the root cause, and I'll post back here when I find out. |
Gleiphir2769
pushed a commit
to Gleiphir2769/pulsar
that referenced
this pull request
Aug 4, 2022
…t to class PulsarResources (apache#16821)
nicoloboschi
pushed a commit
to datastax/pulsar
that referenced
this pull request
Aug 16, 2022
…t to class PulsarResources (apache#16821) (cherry picked from commit 4ee3466) (cherry picked from commit 41d7cf1)
Member
|
I don't see how this could fix the issue. Here's an example of a recent problem |
Merged
1 of 4 tasks
Member
|
@poorbarcode This solution didn't fix the issue. Your analysis of the problem was correct. I have created a solution where the getters are no longer overridden using Mockito. The PR is #19323, please review. |
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
Such as
PersistentTopicTest,ServerCnxAuthorizationTest,PersistentDispatcherFailoverConsumerTestandMessageCumulativeAckTestis very flaky, will throwsClassCastExceptionlike this:I found the cause of the problem: while executing
doReturn(pulsarResources).when(pulsar).getPulsarResources(), Meta Store Thread also accesses variablePulsarService.getPulsarResources()asynchronously in logic:notification by zk-watcher(Concurrent access will be problematic if the object is being mock bound).Modifications
Execute mock-cmd in
meta-thread(The executor of MetaStore is a single thread pool executor, so all things will be thread safety).Documentation
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)