shibd opened a new pull request, #16719:
URL: https://github.com/apache/pulsar/pull/16719

   #16374  #16556 #16375 #16599
   
   ### Motivation
   
   This is a bug, after 
[[PIP-145](https://github.com/apache/pulsar/pull/16062)],  
`PatternMultiTopicsConsumer` can receive  `CommandWatchTopicUpdate` from broker 
to subscribe new topic.
   
   But this topic name is with the partition index(case: 
public/default/test-topic-partition-0), This will produce unexpected behavior 
when executing the following subscribe method.
   
   
https://github.com/apache/pulsar/blob/9c93ab45af80dbeb116bfe9b63ff579ac4e22ce6/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java#L935-L942
   
   
   The reasons for these failed unit tests are:
   
   When the client receives the `CommandWatchTopicUpdate` command, it will 
enter the collection of processing non-partitions, then only process the 
[consumer](https://github.com/apache/pulsar/blob/9c93ab45af80dbeb116bfe9b63ff579ac4e22ce6/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java#L79)
 collection and not the 
[partitionedTopics](https://github.com/apache/pulsar/blob/9c93ab45af80dbeb116bfe9b63ff579ac4e22ce6/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java#L82)
 collection
   
   
https://github.com/apache/pulsar/blob/9c93ab45af80dbeb116bfe9b63ff579ac4e22ce6/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java#L1068-L1094
   
   Then, when we execute the 
`consumer1.run(consumer1.getRecheckPatternTimeout())` to trigger the update 
subscription on the unit test, By executing the following logic, will cause 
`topic-4` to be removed and added at the same time. ultimately destabilizes 
unit tests (maybe deletes will be executed after additions)
   
   
https://github.com/apache/pulsar/blob/9c93ab45af80dbeb116bfe9b63ff579ac4e22ce6/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PatternMultiTopicsConsumerImpl.java#L115-L121
   
   Print log here:
   <img width="1332" alt="image" 
src="https://user-images.githubusercontent.com/33416836/180206241-db6daeea-727e-422f-9861-74f9f16b1525.png";>
   
   Can See:
   
   ```
   2022-07-21T19:43:35,883 - INFO  - 
[pulsar-client-io-397-1:PatternMultiTopicsConsumerImpl@154] - debug add: 
[persistent://my-property/my-ns/pattern-topic-4-AutoSubscribePatternConsumer]
   2022-07-21T19:43:35,883 - INFO  - 
[pulsar-client-io-397-1:PatternMultiTopicsConsumerImpl@155] - debug remove: 
[persistent://my-property/my-ns/pattern-topic-4-AutoSubscribePatternConsumer-partition-0,
 
persistent://my-property/my-ns/pattern-topic-4-AutoSubscribePatternConsumer-partition-1,
 
persistent://my-property/my-ns/pattern-topic-4-AutoSubscribePatternConsumer-partition-2,
 
persistent://my-property/my-ns/pattern-topic-4-AutoSubscribePatternConsumer-partition-3]
   
   ```
   
   ### Modifications
   
   - Change subscribe logic, use the `getPartitionedTopicName()`.
   
   
   ### Documentation
   
   - [x] `doc-not-needed` 
   (Please explain why)
   


-- 
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]

Reply via email to