Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky-test: ClassCastException in ExtensibleLoadManagerImpl.checkOwnershipAsync #21654

Closed
1 task done
lhotari opened this issue Dec 1, 2023 · 6 comments · Fixed by #21668
Closed
1 task done

Flaky-test: ClassCastException in ExtensibleLoadManagerImpl.checkOwnershipAsync #21654

lhotari opened this issue Dec 1, 2023 · 6 comments · Fixed by #21668

Comments

@lhotari
Copy link
Member

lhotari commented Dec 1, 2023

Search before asking

  • I searched in the issues and found nothing similar.

Example failures

Exception stacktrace

org.apache.pulsar.client.admin.PulsarAdminException$ServerSideErrorException:

 --- An unexpected error occurred in the server ---

Message: class java.util.ImmutableCollections$List12 cannot be cast to class java.util.concurrent.CompletableFuture (java.util.ImmutableCollections$List12 and java.util.concurrent.CompletableFuture are in module java.base of loader 'bootstrap')

Stacktrace:

java.lang.ClassCastException: class java.util.ImmutableCollections$List12 cannot be cast to class java.util.concurrent.CompletableFuture (java.util.ImmutableCollections$List12 and java.util.concurrent.CompletableFuture are in module java.base of loader 'bootstrap')
	at org.apache.pulsar.broker.loadbalance.extensions.ExtensibleLoadManagerImpl.checkOwnershipAsync(ExtensibleLoadManagerImpl.java:625)
	at org.apache.pulsar.broker.loadbalance.extensions.ExtensibleLoadManagerWrapper.checkOwnershipAsync(ExtensibleLoadManagerWrapper.java:72)
	at org.apache.pulsar.broker.namespace.NamespaceService.lambda$checkTopicOwnership$47(NamespaceService.java:1230)
	at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1187)
	at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2341)
	at org.apache.pulsar.broker.namespace.NamespaceService.checkTopicOwnership(NamespaceService.java:1230)
	at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
	at org.mockito.internal.util.reflection.InstrumentationMemberAccessor$Dispatcher$ByteBuddy$sc8ugsJW.invokeWithArguments(Unknown Source)
	at org.mockito.internal.util.reflection.InstrumentationMemberAccessor.invoke(InstrumentationMemberAccessor.java:251)
	at org.mockito.internal.util.reflection.ModuleMemberAccessor.invoke(ModuleMemberAccessor.java:55)
	at org.mockito.internal.creation.bytebuddy.MockMethodAdvice.tryInvoke(MockMethodAdvice.java:314)
	at org.mockito.internal.creation.bytebuddy.MockMethodAdvice$RealMethodCall.invoke(MockMethodAdvice.java:234)
	at org.mockito.internal.invocation.InterceptedInvocation.callRealMethod(InterceptedInvocation.java:142)
	at org.mockito.internal.stubbing.answers.CallsRealMethods.answer(CallsRealMethods.java:45)
	at org.mockito.Answers.answer(Answers.java:90)
	at org.mockito.internal.handler.MockHandlerImpl.handle(MockHandlerImpl.java:111)
	at org.mockito.internal.handler.NullResultGuardian.handle(NullResultGuardian.java:29)
	at org.mockito.internal.handler.InvocationNotifierHandler.handle(InvocationNotifierHandler.java:34)
	at org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.doIntercept(MockMethodInterceptor.java:82)
	at org.mockito.internal.creation.bytebuddy.MockMethodAdvice.handle(MockMethodAdvice.java:134)
	at org.apache.pulsar.broker.namespace.NamespaceService.checkTopicOwnership(NamespaceService.java:1228)
	at org.apache.pulsar.broker.service.BrokerService.checkTopicNsOwnership(BrokerService.java:2221)
	at org.apache.pulsar.broker.service.BrokerService.loadOrCreatePersistentTopic(BrokerService.java:1562)
	at org.apache.pulsar.broker.service.BrokerService.lambda$getTopic$30(BrokerService.java:1086)
	at org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap$Section.put(ConcurrentOpenHashMap.java:438)
	at org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap.computeIfAbsent(ConcurrentOpenHashMap.java:257)
	at org.apache.pulsar.broker.service.BrokerService.lambda$getTopic$32(BrokerService.java:1067)
@lhotari
Copy link
Member Author

lhotari commented Dec 1, 2023

@heesung-sn @Demogorgon314 would you mind checking this exception?

@lhotari
Copy link
Member Author

lhotari commented Dec 1, 2023

@lhotari lhotari changed the title [Bug] ClassCastException in ExtensibleLoadManagerImpl.checkOwnershipAsync Flaky-test: ClassCastException in ExtensibleLoadManagerImpl.checkOwnershipAsync Dec 1, 2023
@lhotari
Copy link
Member Author

lhotari commented Dec 1, 2023

This might be an issue with Mockito. Mockito isn't threadsafe in all possible ways. It's documented here how Mockito should be used: https://github.com/mockito/mockito/wiki/FAQ#is-mockito-thread-safe . Previously we have had issues #13620 and #13570 .

@lhotari
Copy link
Member Author

lhotari commented Dec 1, 2023

ExtensibleLoadManagerImplTest also uses org.mockito.MockedStatic . The javadoc of that says "The mocking only affects the thread on which this static mock was created and it is not safe to use this object from another thread.".
It would be better to get rid of mocking of static methods since it won't be thread safe

@heesung-sn
Copy link
Contributor

Hi, I will check this.

@heesung-sn
Copy link
Contributor

Raised a PR to remove the static mock. #21668

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants