-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[fix][broker] Allow recreation of partitioned topic after metadata loss #24225
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@nodece Please check the test failures whether those are valid ones |
@nodece what does "This PR depends on the |
In that case, it's better to remove the release labels until the condition has been addressed. The reason for this is that release labels are used to track cherry-picking of individual PRs. This PR cannot be cherry-picked and therefore it shouldn't contain the label until it's ready. I use some scripts to track cherry-picking across branches using this assumption. This PR would pop up in the cherry-picking queue each time if it's labeled. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #24225 +/- ##
============================================
+ Coverage 73.57% 74.26% +0.69%
+ Complexity 32624 32129 -495
============================================
Files 1877 1866 -11
Lines 139502 144802 +5300
Branches 15299 16540 +1241
============================================
+ Hits 102638 107542 +4904
+ Misses 28908 28771 -137
- Partials 7956 8489 +533
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
hello , I am a new developer for pulsar, our product start to use pulsar, which replace kafka in serverless env. I can learn your pr. I have a little question. why does the actual topic partitions may still exist, but the partitioned metadata is missing? Human error deletion or does not full delete? |
Good catch! This PR description has been updated, please check. |
thanks, I understand. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTest.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Zixuan Liu <[email protected]>
Signed-off-by: Zixuan Liu <[email protected]>
Signed-off-by: Zixuan Liu <[email protected]>
Signed-off-by: Zixuan Liu <[email protected]>
98a08b4
to
e4c0f25
Compare
Signed-off-by: Zixuan Liu <[email protected]>
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
Outdated
Show resolved
Hide resolved
…ss (apache#24225) Signed-off-by: Zixuan Liu <[email protected]> (cherry picked from commit 2dd1ef6) Signed-off-by: Zixuan Liu <[email protected]> # Conflicts: # pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java # pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java # pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTest.java
…ss (apache#24225) Signed-off-by: Zixuan Liu <[email protected]> (cherry picked from commit 2dd1ef6) Signed-off-by: Zixuan Liu <[email protected]>
Motivation
In Pulsar, it's possible for actual partition topics (e.g.,
public/default/test-partitioned-topic-partition-1
) to exist even though the corresponding partitioned topic metadata is missing. This inconsistency can occur due to human error (e.g., accidental deletion of metadata) or implicit topic creation via auto-topic creation settings.Specifically, if
allowAutoTopicCreation=true
andallowAutoTopicCreationType=non-partitioned
, then producing or consuming directly from a partition topic name liketest-partitioned-topic-partition-1
will cause Pulsar to auto-create a non-partitioned topic. This leads to an inconsistent state: the topic appears intopics list
, but not intopics list-partitioned-topics
. From the user's perspective, they expect to see a partitioned topic, but instead,list-partitioned-topics
returns nothing, leading to confusion and potential automation failures.Steps to reproduce:
Once such a partition is mistakenly created as a non-partitioned topic, it is no longer possible to convert it into a partitioned topic, because Pulsar does not allow overwriting existing topics. This results in effective metadata loss. A similar issue can occur in geo-replication scenarios, where only the individual partition topics are replicated, but the partitioned topic metadata is not.
Moreover, if the partitioned topic metadata is lost, running
pulsar-admin topics create-partitioned-topic
fails to recreate it:In this case, the partition still exist, but the partitioned topic metadata is missing—causing a
409 Conflict
when attempting to recreate it.Modifications
pulsar().getNamespaceService().checkTopicExists(topicName)
to verify the existence of the topic or its metadata. If the topic or its metadata does not exist, the system proceeds with the creation of the partitioned topic, allowing its recreation.Documentation
doc
doc-required
doc-not-needed
doc-complete