Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maxTopicsPerNamespace check should exclude system topic. #10850

Merged
merged 15 commits into from
Jun 22, 2021

Conversation

yangl
Copy link
Contributor

@yangl yangl commented Jun 7, 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?

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

@yangl yangl marked this pull request as ready for review June 8, 2021 07:28
Copy link
Contributor Author

@yangl yangl left a comment

Choose a reason for hiding this comment

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

done.

@BewareMyPower
Copy link
Contributor

BewareMyPower commented Jun 8, 2021

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
Copy link
Contributor Author

yangl commented Jun 8, 2021

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.

Copy link
Contributor

@BewareMyPower BewareMyPower left a comment

Choose a reason for hiding this comment

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

LGTM

@Anonymitaet
Copy link
Member

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

@yangl
Copy link
Contributor Author

yangl commented Jun 8, 2021

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

No, it doesn't involve docs.

@yangl
Copy link
Contributor Author

yangl commented Jun 8, 2021

/pulsarbot run-failure-checks

Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

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
Contributor

@315157973 @michaeljmarshall Could you take a look again?

@sijie
Copy link
Member

sijie commented Jun 18, 2021

@315157973 @michaeljmarshall Could you take a look again?

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

@michaeljmarshall michaeljmarshall left a comment

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.

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
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
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>
Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

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.

Copy link
Contributor

@eolivelli eolivelli left a comment

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