You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 16, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 16, 2026. It is now read-only.
Describe the bug
We disabled the DistributedClusterTest in #207 because these tests cannot pass in CI environment though they can pass in local environment. The track issue is #184 .
However, I found the testMutiBrokerUnloadReload cannot pass even in local environment. The other two tests of DistributedClusterTest work well.
[ERROR] testMutiBrokerUnloadReload(io.streamnative.pulsar.handlers.kop.DistributedClusterTest) Time elapsed: 30.013 s <<< FAILURE!
org.testng.internal.thread.ThreadTimeoutException: Method io.streamnative.pulsar.handlers.kop.DistributedClusterTest.testMutiBrokerUnloadReload() didn't finish within the time-out 30000
at java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:457)
at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.poll(ConsumerNetworkClient.java:299)
at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.poll(ConsumerNetworkClient.java:242)
at org.apache.kafka.clients.consumer.KafkaConsumer.pollForFetches(KafkaConsumer.java:1247)
at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1187)
at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1154)
at io.streamnative.pulsar.handlers.kop.DistributedClusterTest.kafkaConsumeCommitMessage(DistributedClusterTest.java:237)
at io.streamnative.pulsar.handlers.kop.DistributedClusterTest.testMutiBrokerUnloadReload(DistributedClusterTest.java:447)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.InvokeMethodRunnable.runOne(InvokeMethodRunnable.java:54)
at org.testng.internal.InvokeMethodRunnable.run(InvokeMethodRunnable.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Expected behavior testMutiBrokerUnloadReload should pass.
Additional context
The issue seems to be introduced from #193 , see following two commits:
This problem is not caused not by PR #193.
The reason is that after unload the namespace, when consumer continue consume, broker still use the origin cursor which has been closed.
First, we get the topicsAndCursor by invoke KafkaTopicManager#getTopicConsumerManager which return KafkaTopicConsumerManager using consumerTopicManagers.computeIfAbsen(. So, if already have TopicConsumerManager for a topic in consumerTopicManagers, consumer will re-use the old TopicConsumerManager which has been closed when namespace being unload.
publicCompletableFuture<KafkaTopicConsumerManager> getTopicConsumerManager(StringtopicName) {
returnconsumerTopicManagers.computeIfAbsent(
topicName,
t -> {
CompletableFuture<PersistentTopic> topic = getTopic(t);
checkState(topic != null);
returntopic.thenApply(t2 -> {
if (log.isDebugEnabled()) {
log.debug("[{}] Call getTopicConsumerManager for {}, and create TCM for {}.",
requestHandler.ctx.channel(), topicName, t2);
}
if (t2 == null) {
returnnull;
}
// return consumer managerreturnnewKafkaTopicConsumerManager(requestHandler, t2);
});
}
);
Before PR #193, when invoke KafkaTopicManager#getTopic from sendMessage request or Fetch request, broker will register a internal producer in topic. So, when unload the namespace, connection will be closed for kafka producer or consumer. But it's incorrect since we should not register a producer for kafka consuemr.
And RP #193 remove the un-necessary register for kafka consumer, connnect for kafka consuemr will not be closed when unload namespace, so it will re-use the old TopicConsumerManager and cursors are already closed.
Activity
BewareMyPower commentedon Dec 4, 2020
When I revert the changes of #193 , the tests passed. I'll push a PR to revert the changes later.
And @aloyszhang could you help take a look at
testMutiBrokerUnloadReloadissue?aloyszhang commentedon Dec 7, 2020
@BewareMyPower I'll check this.
aloyszhang commentedon Dec 8, 2020
This problem is not caused not by PR #193.

The reason is that after unload the namespace, when consumer continue consume, broker still use the origin cursor which has been closed.
The logic of
handleFetchRequestisFirst, we get the
topicsAndCursorby invokeKafkaTopicManager#getTopicConsumerManagerwhich returnKafkaTopicConsumerManagerusingconsumerTopicManagers.computeIfAbsen(. So, if already haveTopicConsumerManagerfor a topic inconsumerTopicManagers, consumer will re-use the oldTopicConsumerManagerwhich has been closed when namespace being unload.BewareMyPower commentedon Dec 8, 2020
What I'm still confused is that why the outdated
TopicConsumerManagerwouldn't be reused after applyingSince it only affects the producer side but just solve the problem.
aloyszhang commentedon Dec 9, 2020
Before PR #193, when invoke
KafkaTopicManager#getTopicfrom sendMessage request or Fetch request, broker will register a internal producer in topic. So, when unload the namespace, connection will be closed for kafka producer or consumer. But it's incorrect since we should not register a producer for kafka consuemr.And RP #193 remove the un-necessary register for kafka consumer, connnect for kafka consuemr will not be closed when unload namespace, so it will re-use the old
TopicConsumerManagerand cursors are already closed.BewareMyPower commentedon Feb 5, 2021
@aloyszhang Could you take a look at this issue again?
fix issue streamnative#252 bundle unload bug
fix issue streamnative#252 bundle unload bug
fix issue streamnative#252 bundle unload bug
fix issue streamnative#252 bundle unload bug
fix issue streamnative#252 bundle unload bug
fix issue streamnative#252 bundle unload bug
fix issue streamnative#252 bundle unload bug
fix issue #252 bundle unload bug (#404)