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

   ### Motivation
   
   #### Background of Admin API `PersistentTopics.getSubscriptions`
   It works like this:
   1. getSubscriptions( `tp1` )
   2. is partitioned topic? 
     `no`: return subscriptions
     `yes`: 
getSubscriptions(`tp1-partition-0`)....getSubscriptions(`tp1-partition-n`)
   
   --- 
   
   #### Background of the issue of `TopicName.getPartition(int index)`
   ```java
   String partitionedTopic = "tp1-partition-0-DLQ";
   
   TopicName partition0 = partitionedTopic.getPartition(0);// Highlight: the 
partition0.toString() will be "tp1-partition-0-DLQ"(it is wrong).The correct 
value is "tp1-partition-0-DLQ-partition-0"
   ```
   
   see: 
   
   
https://github.com/apache/pulsar/blob/da788794ebe211bc96d4d961de49ffeeb473ffad/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java#L233-L237
   
   #### Issue
   Therefore, if there has a partitioned topic named `tp1-partition-0-DLQ`, the 
method `PersistentTopics.getSubscriptions` will works like this:
   1. call Admin API ``PersistentTopics.getSubscriptions("tp1-partition-0-DLQ")`
   2. is partitioned topic? 
   3. yes, call `TopicName.getPartition(0)` to get partition 0 and will get 
`tp1-partition-0-DLQ` , then loop to step-1.
   
   Then the infinite HTTP call `PersistentTopics.getSubscriptions` makes the 
broker crash.
   
   ### Modifications
   
   #### Quick fix(this PR does it)
   If hits the issue which makes the topic name wrong, do not loop to step 1.
   
   #### Long-term fix
   The PR https://github.com/apache/pulsar/pull/19841 fixes the issue which 
makes the topic name wrong, and this PR will create unfriendly compatibility, 
and PIP 263 https://github.com/apache/pulsar/issues/20033 will make 
compatibility good.
   
   
   ### 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: 
   - https://github.com/poorbarcode/pulsar/pull/88


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