poorbarcode opened a new pull request, #25312:
URL: https://github.com/apache/pulsar/pull/25312
### Motivation
The situation that replication does not work as expected.
- cluster: `c1`
- namespace: `public/default`
The system topic `__change_events` has already been created as a
non-partitioned topic; in other words, the topic named `__change_events` has no
partition.
- cluster: `c2`, has the following configurations
- `allowAutoTopicCreationType=partitioned`
- `defaultNumPartitions=1`
These two configurations mean that the new topic will be created as a
partitioned topic and contain `1` partition.
If we enable replication for the namespace between two clusters, the
following issue will happen
- The cluster `c2` will create a partitioned topic `__change_events` , and
it will have a partition like this `__change_events-partition-0`
- The cluster `c1` will start replication for the non-partitioned topic
`__change_events`, which triggers a non-partitioned topic creation on the `c2`
cluster.
- `c2` will also start a replication to `c1` since it has a partitioned
topic which has a partition named `__change_events-partition-0`, it triggers a
partitioned creation on `c1` cluster.
Eventually, both clusters will hold both partitioned topics and
non-partitioned topics as follows, but they have the same name.
- `admin/partitioned-toipic`: `{partitions: 1}`
- `managed-ledger/persistent`: `[__change_events-partition-0,
__change_events]`
Because this is a system topic, it will lead to fragmentation and cause
serious problems
### Modifications
- Create a topic with the same type as the remote side, if the topic has
already been created on the remote side.
- The change only affects if the following conditions match
- Enable replication
- The topic creation was triggered by `consumer/producer`'s starting
- The remote side has already created the topic
- `broker.conf -> isCreateTopicToRemoteClusterForReplication` is `true`
- enabled topic auto-creation
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update
later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: x
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]