BewareMyPower commented on code in PR #24920:
URL: https://github.com/apache/pulsar/pull/24920#discussion_r2486182394
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherSingleActiveConsumer.java:
##########
@@ -176,6 +176,11 @@ public synchronized CompletableFuture<Void>
addConsumer(Consumer consumer) {
return FutureUtil.failedFuture(new
ConsumerBusyException("Exclusive consumer is already"
+ " connected"));
} else {
+ try {
+ removeConsumer(actConsumer);
+ } catch (BrokerServiceException e) {
+ log.warn("[{}] Remove inactive exclusive consumer
{}", this.topicName, consumer);
+ }
Review Comment:
@lhotari I think the previous change here is correct:
https://github.com/apache/pulsar/pull/24920/commits/bcb763baa670544ea90bda67243870d5ef085551
`channelInactive` is not synchronized with `addConsumer`, so there is a race
condition.
1. `isActive = false` is called:
https://github.com/apache/pulsar/blob/402ed5bc0a50b07fc7baff6c9c6a0ed0eb07a6b5/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java#L411
2. `addConsumer` is called on a new consumer
3. `consumer.close()` is called:
https://github.com/apache/pulsar/blob/402ed5bc0a50b07fc7baff6c9c6a0ed0eb07a6b5/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java#L447
Then step 2 will always fail with `StackOverflowError`.
```
2025-10-28T22:54:08,431+0000 [configuration-metadata-store-14-1] ERROR
org.apache.pulsar.broker.service.persistent.PersistentTopic -
[persistent://public/default/test-partition-0] Failed to create subscription:
test-subscription
java.util.concurrent.CompletionException: java.lang.StackOverflowError
```
From the thread name, we can see the `StackOverflowError` error happens in
the metadata store thread. However, if the consumer's connection (`ServerCnx`)
is active, the future will always complete in a Netty event loop thread, whose
name starts with `pulsar-io`.
https://github.com/apache/pulsar/blob/402ed5bc0a50b07fc7baff6c9c6a0ed0eb07a6b5/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java#L3697
https://github.com/apache/pulsar/blob/402ed5bc0a50b07fc7baff6c9c6a0ed0eb07a6b5/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java#L3707
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]