Skip to content

maxTopicsPerNamespace check should exclude system topic. - #10850

Merged
BewareMyPower merged 15 commits into
apache:masterfrom
yangl:maxTopicsPerNamespace
Jun 22, 2021
Merged

maxTopicsPerNamespace check should exclude system topic.#10850
BewareMyPower merged 15 commits into
apache:masterfrom
yangl:maxTopicsPerNamespace

Conversation

@yangl

@yangl yangl commented Jun 7, 2021

Copy link
Copy Markdown
Contributor

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?

        // 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 dd8be83#diff-445b0cfa56ca0c784df78e73d9294f2a37f079ca3c15c345b03c09d56f81ebffR204 by @BewareMyPower

@yangl
yangl marked this pull request as draft June 7, 2021 10:00
@yangl
yangl marked this pull request as ready for review June 7, 2021 11:32
@yangl
yangl marked this pull request as draft June 7, 2021 13:39
@BewareMyPower

Copy link
Copy Markdown
Contributor

In addition, why is mytopic-partition--1 is a partitioned topic(with --)? Which version of us uses this logic?

This comment was marked by me. Though it's a wrong behavior, like -partition-00 and -partition-012 should not be treated as a valid partition, if it was changed, the other client may not be compatible with the broker anymore.

Comment thread pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java Outdated
@yangl
yangl marked this pull request as ready for review June 8, 2021 07:28

@yangl yangl left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Comment thread pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java Outdated
@BewareMyPower

BewareMyPower commented Jun 8, 2021

Copy link
Copy Markdown
Contributor

Could you add a test case to cover your change? Your test only covers the isSystemTopic method.

I mean changing AdminApiTest2#testMaxTopicsPerNamespace. Could you manually create some system topics and see if the test could be affected?

@yangl

yangl commented Jun 8, 2021

Copy link
Copy Markdown
Contributor Author

Could you add a test case to cover your change? Your test only covers the isSystemTopic method.

I mean changing AdminApiTest2#testMaxTopicsPerNamespace. Could you manually create some system topics and see if the test could be affected?

done.

@BewareMyPower BewareMyPower left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Anonymitaet

Copy link
Copy Markdown
Member

@yangl thanks for your contribution. For this PR, do we need to update docs?

@yangl

yangl commented Jun 8, 2021

Copy link
Copy Markdown
Contributor Author

@yangl thanks for your contribution. For this PR, do we need to update docs?

No, it doesn't involve docs.

@yangl

yangl commented Jun 8, 2021

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@michaeljmarshall michaeljmarshall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@yangl
yangl marked this pull request as draft June 10, 2021 07:46
@yangl
yangl marked this pull request as ready for review June 10, 2021 10:35
@yangl
yangl requested a review from 315157973 June 10, 2021 10:37
@BewareMyPower

Copy link
Copy Markdown
Contributor

@315157973 @michaeljmarshall Could you take a look again?

@sijie

sijie commented Jun 18, 2021

Copy link
Copy Markdown
Member

@315157973 @michaeljmarshall Could you take a look again?

@sijie sijie added this to the 2.9.0 milestone Jun 18, 2021

@michaeljmarshall michaeljmarshall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yangl - thanks for addressing my initial comments. Those changes look good. I left some comments on optimizations I think we should implement.

Comment thread pulsar-common/src/main/java/org/apache/pulsar/common/events/EventsTopicNames.java Outdated
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)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 michaeljmarshall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yangl - thanks for addressing my comments. LGTM.

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BewareMyPower
BewareMyPower merged commit dbcaa98 into apache:master Jun 22, 2021
@yangl
yangl deleted the maxTopicsPerNamespace branch June 23, 2021 01:10
yangl added a commit to yangl/pulsar that referenced this pull request Jun 23, 2021
### 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
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
### 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants