-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fix][broker] Partitioned shadow topic not work properly #22797
[fix][broker] Partitioned shadow topic not work properly #22797
Conversation
@RobertIndie Please add the following content to your PR description and select a checkbox:
|
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
Do we have a discussion about it? |
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
The discussion happens on this PR currently. |
I mean this should be discussed in the mail list. There are some behavior change. |
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/ShadowTopicTest.java
Outdated
Show resolved
Hide resolved
@liangyepianzhou IMO, if it didn't add some validations to the existing |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #22797 +/- ##
============================================
- Coverage 73.57% 73.34% -0.24%
- Complexity 32624 33196 +572
============================================
Files 1877 1901 +24
Lines 139502 142526 +3024
Branches 15299 15573 +274
============================================
+ Hits 102638 104529 +1891
- Misses 28908 29980 +1072
- Partials 7956 8017 +61
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Motivation
Currently, when we create a shadow topic for a partitioned topic, the shadow topic won't get any messages from the source topic.
Root cause
Suppose we have a shadow topic
test-shadow
which shadows messages from the source topictest
. And they should all be the partitioned topic. When initializing the ShadowManagedLedger for thetest-shadow-partition-0
, it will create a ShadowReplicator that gets messages fromtest-partition-0
but replicates messages to the wrong topictest-shadow
. Therefore the shadow topic won't get any messages.Solution
The solution is to create each ShadowReplicator replicate message from
test-partition-X
totest-shadow-partition-X
. In this way, we could also ensure the message ordering.However, the shadow topic must have more partitions than the source topic. When the source topic expands its number of partitions, we cannot automatically increase the partitions of the shadow topic because it may be in a different namespace with distinct permissions and configurations.
Therefore, I suggest that before expanding the source topic, we should first check if all associated shadow topics have been expanded. If not, we should throw an error to inform the user to expand all shadow topics first. Also, when setting up the shadow topic for the source topic, avoid adding "-partition-N" at the end. Otherwise, the ShadowReplicator will not function properly. And in that case, we should also throw the exception to inform the user.
After the discussion, I will split this solution into two parts:
-partition-X
as the shadow topic.This PR will only handle the part 1.
Modifications
The following modifications will be split as a separate PR:
-partition-X
as the shadow topic.Verifying this change
This change added tests.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: