poorbarcode opened a new pull request, #22025: URL: https://github.com/apache/pulsar/pull/22025
### Motivation If a consumer tries to subscribe to a partitioned topic with a suffix-matched regexp, it does not work. - create topic `persistent://public/default/tp` - create a consumer with regexp `persistent://public/default/tp$` - the pattern consumer has no internal consumers. You can reproduce the issue by the test `testPreciseRegexpSubscribe`. - it can work when using `2.10.x` - it can not work when using `>=2.11.0`, it is a break change due to [PIP-145](https://github.com/apache/pulsar/issues/14505) https://github.com/apache/pulsar/pull/21885 fixed one wrong logic [here](https://github.com/apache/pulsar/pull/21885/files#diff-a36b69990c877e8ddc805bab84f15c3b119d42e152ba137d17e02e6909b0089cR54-R58), but there is still another wrong logic, see https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java#L64 ```java @Override public void accept(String topicName, NotificationType notificationType) { // The param "topicName" contains the partition suffix, which causes a suffix-matched regexp not to match. if (topicsPattern.matcher(topicName).matches()) { List<String> newTopics; List<String> deletedTopics; ... ``` --- ### Why can the test `testPreciseRegexpSubscribe` pass? https://github.com/apache/pulsar/pull/21885 added a test `testPreciseRegexpSubscribe` that covers the test which creates a consumer with a suffix-matched regexp. It works as below: - create a consumer with a suffix-matched regexp - create a partitioned topic - two events will trigger the pattern consumer to auto-create an internal single partition consumer. - Start a new `recheckTopicsChangeAfterReconnect` after the topic watcher is connected. https://github.com/apache/pulsar/pull/21885 fixed the wrong behavior. - Receive an event that a new topic created. Current PR is trying to fix the wrong behavior. The test `testPreciseRegexpSubscribe` can not pass as the below flow: - create a consumer with a suffix-matched regexp - wait for Topic List Watcher to start. - the consumer will call `recheckTopicsChangeAfterReconnect` at this step. - create a partitioned topic - the consumer can not receive the event due to the wrong logic, then the test failed. --- ### Modifications - Review all the codes of the Topic List Watcher and add descriptions of the `topic name`. - Fix the wrong behavior. --- ### Documentation <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> - [ ] `doc` <!-- Your PR contains doc changes. --> - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later --> - [x] `doc-not-needed` <!-- Your PR changes do not impact docs --> - [ ] `doc-complete` <!-- Docs have been already added --> ### Matching PR in forked repository PR in forked repository: x -- 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]
