maxTopicsPerNamespace check should exclude system topic. - #10850
Conversation
Signed-off-by: YANGLiiN <ielin@qq.com>
This comment was marked by me. Though it's a wrong behavior, like |
|
Could you add a test case to cover your change? Your test only covers the I mean changing |
done. |
|
@yangl thanks for your contribution. For this PR, do we need to update docs? |
No, it doesn't involve docs. |
|
/pulsarbot run-failure-checks |
michaeljmarshall
left a comment
There was a problem hiding this comment.
I agree that system topics shouldn't count against the max topic limit per namespace. I left some comments for potential edge cases that I think need to be considered.
# Conflicts: # pulsar-common/src/main/java/org/apache/pulsar/common/events/EventsTopicNames.java
|
@315157973 @michaeljmarshall Could you take a look again? |
|
@315157973 @michaeljmarshall Could you take a look again? |
michaeljmarshall
left a comment
There was a problem hiding this comment.
@yangl - thanks for addressing my initial comments. Those changes look good. I left some comments on optimizations I think we should implement.
| return EventsTopicNames.NAMESPACE_EVENTS_LOCAL_NAME.equals(topicName.getLocalName()); | ||
| String localName = TopicName.get(topicName.getPartitionedTopicName()).getLocalName(); | ||
| // transaction pending ack topic | ||
| if (StringUtils.endsWith(localName, MLPendingAckStore.PENDING_ACK_STORE_SUFFIX)) { |
There was a problem hiding this comment.
@sijie - I am concerned that this logic technically includes user topics. That technically leaves users open to accidentally (or intentionally) creating topics that could be classified as system topics. Given the change in this PR, letting a topic end in this special suffix could allow users to create topics and exceed a namespace's topic limit (assuming the limit is enabled). I don't think this comment should prevent us from merging this PR, but I do think we should address this concern at some point.
There was a problem hiding this comment.
@sijie Could you take a look at @michaeljmarshall 's comment?
BTW, I'll merge this PR first.
Signed-off-by: YANGLiiN <ielin@qq.com>
michaeljmarshall
left a comment
There was a problem hiding this comment.
@yangl - thanks for addressing my comments. LGTM.
### Motivation
The current maxTopicsPerNamespace check logic contains system topics, but it should be excluded. As the even if we turn off `allowAutoTopicCreation`, the systemtopic will auto creation too.
### Modifications
1. Exclude the system topics for the maxTopicsPerNamespace logic.
2. SystemTopic add the missed logic, such as `__transaction_buffer_snapshot` 、start with the `__transaction_buffer_snapshot` end with the `__transaction_pending_ack`.
In addition, why is mytopic-partition--1 is a partitioned topic(with --)? Which version of us uses this logic?
```java
// NOTE: Following behavior is not right actually, but for the backward compatibility, it shouldn't be changed
assertEquals(TopicName.getPartitionIndex("mytopic-partition--1"), 1);
assertEquals(TopicName.getPartitionIndex("mytopic-partition-00"), 0);
assertEquals(TopicName.getPartitionIndex("mytopic-partition-012"), 12);
```
this testcase added with apache@dd8be83#diff-445b0cfa56ca0c784df78e73d9294f2a37f079ca3c15c345b03c09d56f81ebffR204 by @BewareMyPower
### Motivation
The current maxTopicsPerNamespace check logic contains system topics, but it should be excluded. As the even if we turn off `allowAutoTopicCreation`, the systemtopic will auto creation too.
### Modifications
1. Exclude the system topics for the maxTopicsPerNamespace logic.
2. SystemTopic add the missed logic, such as `__transaction_buffer_snapshot` 、start with the `__transaction_buffer_snapshot` end with the `__transaction_pending_ack`.
In addition, why is mytopic-partition--1 is a partitioned topic(with --)? Which version of us uses this logic?
```java
// NOTE: Following behavior is not right actually, but for the backward compatibility, it shouldn't be changed
assertEquals(TopicName.getPartitionIndex("mytopic-partition--1"), 1);
assertEquals(TopicName.getPartitionIndex("mytopic-partition-00"), 0);
assertEquals(TopicName.getPartitionIndex("mytopic-partition-012"), 12);
```
this testcase added with apache@dd8be83#diff-445b0cfa56ca0c784df78e73d9294f2a37f079ca3c15c345b03c09d56f81ebffR204 by @BewareMyPower
Motivation
The current maxTopicsPerNamespace check logic contains system topics, but it should be excluded. As the even if we turn off
allowAutoTopicCreation, the systemtopic will auto creation too.Modifications
__transaction_buffer_snapshot、start with the__transaction_buffer_snapshotend with the__transaction_pending_ack.In addition, why is mytopic-partition--1 is a partitioned topic(with --)? Which version of us uses this logic?
this testcase added with dd8be83#diff-445b0cfa56ca0c784df78e73d9294f2a37f079ca3c15c345b03c09d56f81ebffR204 by @BewareMyPower