[fix][flaky-test] Fix ClassCastException: BrokerService cannot be cast to class PulsarResources#16821
Conversation
…t to class PulsarResources
|
@poorbarcode The same problem is happening here, can you take a look at it together? #16666 |
shibd
left a comment
There was a problem hiding this comment.
Nice catch! I tested it locally and it can work.
Thanks. |
|
/pulsarbot rerun-failure-checks |
|
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. |
…t to class PulsarResources (apache#16821)
…t to class PulsarResources (apache#16821) (cherry picked from commit 4ee3466) (cherry picked from commit 41d7cf1)
|
I don't see how this could fix the issue. Here's an example of a recent problem happens in https://github.com/apache/pulsar/actions/runs/3875096798/jobs/6609869449#step:11:1088 |
|
@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. |
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)