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

[improve] [pip] PIP-370: configurable remote topic creation in geo-replication #23124

Merged
merged 18 commits into from
Aug 16, 2024
Merged
57 changes: 57 additions & 0 deletions pip/pip-370.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# PIP-370: configurable remote topic creation in geo-replication

# Background knowledge

**The current topic creation behavior when enabling Geo-Replication**
Users using Geo-Replication backup data across multiple clusters, as well as Admin APIs related to Geo-Replication and internal replicators of brokers, will trigger topics of auto-creation between clusters.
- For partitioned topics.
- After enabling namespace-level Geo-Replication: the broker will create topics on the remote cluster automatically when calling `pulsar-admin topics create-partitioned-topic`. It does not depend on enabling `allowAutoTopicCreation`.
- When enabling topic-level Geo-Replication on a partitioned topic: the broker will create topics on the remote cluster automatically. It does not depend on enabling `allowAutoTopicCreation`.
- For non-partitioned topics and partitions of partitioned topics.
- The internal Geo-Replicator will trigger topics auto-creation for remote clusters. **(Highlight)** It depends on enabling `allowAutoTopicCreation`. In fact, this behavior is not related to Geo-Replication, it is the behavior of the internal producer of Geo-Replicator,

# Motivation

In the following scenarios, automatic topic creation across clusters is problematic due to race conditions during deployments, and there is no choice that prevents pulsar resource creation affects each other between clusters.

- Users want to maintain pulsar resources manually.
- Users pulsar resources using `GitOps CD` automated deployment, for which
- Clusters are deployed simultaneously without user intervention.
- Each cluster is precisely configured from git repo config variables - including the list of all tenants/namespaces/topics to be created in each cluster.
- Clusters are configured to be exact clones of each other in terms of pulsar resources.

**Passed solution**: disable `allowAutoTopicCreation`, the APIs `pulsar-admin topics create-partitioned-topic` still create topics on the remote cluster when enabled namespace level replication, the API `enable topic-level replication` still create topics, And the internal replicator will keep printing error logs due to a not found error.
poorbarcode marked this conversation as resolved.
Show resolved Hide resolved

# Goals

Introduce a flag to disable the replicators to automatically trigger topic creation.

# Detailed Design

## Configuration

**broker.conf**
```properties
# It is not a dynamic config, the default value is "true" to preserve backward-compatible behavior.
# See details below.
poorbarcode marked this conversation as resolved.
Show resolved Hide resolved
createTopicToRemoteClusterForReplication=true
```

## Design & Implementation Details

- If `createTopicToRemoteClusterForReplication` is set to `false`.
1. After enabling namespace-level Geo-Replication: the broker will not create topics on the remote cluster automatically when calling `pulsar-admin topics create-partitioned-topic`.
codelipenghui marked this conversation as resolved.
Show resolved Hide resolved
2. When enabling topic-level Geo-Replication on a partitioned topic: broker will not create topics on the remote cluster automatically.
3. The internal Geo-Replicator will not trigger topic auto-creation for remote clusters, it just keeps retrying to check if the topic exists on the remote cluster, once the topic is created, the replicator starts.
4. It does not change the behavior that creating subscriptions after enabling `enableReplicatedSubscriptions`, the subscription will also be created on the remote cluster after users enable. `enableReplicatedSubscriptions`.
5. The config `allowAutoTopicCreation` still works for the local cluster as before, it will not be affected by the new config `createTopicToRemoteClusterForReplication`.
- If `createTopicToRemoteClusterForReplication` is set to `true`.
a. All components work as before, see details: `Motivation -> The current topic creation behavior when enabling Geo-Replication`

# Backward & Forward Compatibility

This PIP guarantees full compatibility with default settings(the default value of `createTopicToRemoteClusterForReplication` is `true`). If you want to cherry-pick PIP-370 for another branch in the future, you need to cherry-pick PIP-344 as well. Because the behavior of disables `createTopicToRemoteClusterForReplication` depends on the API `PulsarClient.getPartitionsForTopic(String topic, boolean metadataAutoCreationEnabled)`, which was introduced by [PIP-344](https://github.com/apache/pulsar/blob/master/pip/pip-344.md).

# Links
* Mailing List discussion thread: https://lists.apache.org/thread/9fx354cqcy3412w1nx8kwdf9h141omdg
* Mailing List voting thread: https://lists.apache.org/thread/vph22st5td1rdh1gd68gkrnp9doo6ct2