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

[Transaction] Fix transaction system topic create in loop. #12749

Conversation

congbobo184
Copy link
Contributor

@congbobo184 congbobo184 commented Nov 11, 2021

fix #12727

Motivation

Now transaction system topic can be created.

Modifications

we should not allow broker or user create by transaction system format topic.

  1. checkout topic auto create.
  2. admin create topic.

Verifying this change

add some test for it

@congbobo184 congbobo184 self-assigned this Nov 11, 2021
@congbobo184 congbobo184 added cherry-picked/branch-2.8 Archived: 2.8 is end of life cherry-picked/branch-2.9 Archived: 2.9 is end of life doc-required Your PR changes impact docs and you will update later. labels Nov 11, 2021
@congbobo184 congbobo184 added this to the 2.10.0 milestone Nov 11, 2021
String topic = topicName.toString();
return topic.startsWith(TopicName.TRANSACTION_COORDINATOR_ASSIGN.toString())
|| topic.startsWith(TopicName.get(TopicDomain.persistent.value(),
NamespaceName.SYSTEM_NAMESPACE, TRANSACTION_LOG_PREFIX).toString())
|| topic.endsWith(MLPendingAckStore.PENDING_ACK_STORE_SUFFIX);
}

public static boolean isNotAllowedToCreateTopic(TopicName topicName) {
String topic = topicName.toString();
return topic.startsWith(TopicName.get(TopicDomain.persistent.value(),
Copy link
Contributor

Choose a reason for hiding this comment

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

what about creating a constant for this ? "TopicName.get(TopicDomain.persistent.value(), NamespaceName.SYSTEM_NAMESPACE, TRANSACTION_LOG_PREFIX).toString()"

@@ -244,6 +245,13 @@ protected void validateAdminAndClientPermission() {
}
}

protected void validateTopicAllowdToCreate(TopicName topicName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: validateCreateTopic

@eolivelli
Copy link
Contributor

Can you add my reproducer as a test case ?

I am not sure that we will really fix the problem. Because we are not forbidding to create a topic with a system name.
But in my case the topic creation is triggered by getSubscriptions().
We do not want getSubscriptions() to fail

@codelipenghui codelipenghui added release/2.8.3 release/2.9.1 and removed cherry-picked/branch-2.8 Archived: 2.8 is end of life cherry-picked/branch-2.9 Archived: 2.9 is end of life labels Nov 12, 2021
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.

I left one last minor comment.

|| topic.endsWith(MLPendingAckStore.PENDING_ACK_STORE_SUFFIX);
}

public static boolean isNotAllowedToCreateTopic(TopicName topicName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what about naming this method isTransactionInternalName ?
the meaning is that this is a reserved name

I see that you are using this method while listing the topic names, so "Create" is not good in that place

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

@congbobo184 congbobo184 merged commit 2c4d913 into apache:master Nov 13, 2021
eolivelli pushed a commit that referenced this pull request Nov 15, 2021
fix #12727
Now transaction system topic can be created.

we should not allow broker or user create by transaction system format topic.

1. checkout topic auto create.
2. admin create topic.

add some test for it

(cherry picked from commit 2c4d913)
@Anonymitaet
Copy link
Member

Anonymitaet commented Nov 19, 2021

Confirmed w/ @codelipenghui, this PR is a bug fix, no need to update docs.

@Anonymitaet Anonymitaet removed the doc-required Your PR changes impact docs and you will update later. label Nov 19, 2021
@Anonymitaet Anonymitaet added the doc-not-needed Your PR changes do not impact docs label Nov 19, 2021
@codelipenghui codelipenghui added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Nov 26, 2021
eolivelli pushed a commit to eolivelli/pulsar that referenced this pull request Nov 29, 2021
)

fix apache#12727
### Motivation
Now transaction system topic can be created.

### Modifications
we should not allow broker or user create by transaction system format topic.

1. checkout topic auto create.
2. admin create topic.

### Verifying this change

add some test for it
eolivelli pushed a commit that referenced this pull request Dec 15, 2021
fix #12727
### Motivation
Now transaction system topic can be created.

### Modifications
we should not allow broker or user create by transaction system format topic.

1. checkout topic auto create.
2. admin create topic.

### Verifying this change

add some test for it

(cherry picked from commit 2c4d913)
@eolivelli eolivelli added cherry-picked/branch-2.9 Archived: 2.9 is end of life release/2.9.0 and removed release/2.9.1 labels Dec 15, 2021
@congbobo184 congbobo184 deleted the congbobo184_fix_create_transaction_system_topic branch March 24, 2022 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/transaction cherry-picked/branch-2.8 Archived: 2.8 is end of life cherry-picked/branch-2.9 Archived: 2.9 is end of life doc-not-needed Your PR changes do not impact docs release/2.8.3 release/2.9.0
Projects
None yet
5 participants