Skip to content

Conversation

nodece
Copy link
Member

@nodece nodece commented Aug 20, 2025

PIP: #24485

Motivation

In a GEO replication scenario, if the remote cluster does not have the replicated topic and the auto-creation type differs between the local and remote clusters, message replication may fail. To ensure seamless replication, the topic metadata must be properly synchronized across clusters.

This is part of PIP-433.

#24136 is the same as this PR.

Modifications

  • When both the local and remote partitioned topic metadata indicate partitions=0, this means the topic is non-partitioned. In this case, the local cluster sends a non-partitioned topic creation request to the remote cluster.

  • If the local partitioned topic metadata has partitions>0, this means the topic is partitioned:

    • If the remote partitioned topic metadata has partitions=0, the local cluster sends a partitioned topic creation request to the remote cluster.
    • If partitions differ between the local and remote cluster, please stop GEO.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Aug 20, 2025
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
@nodece nodece force-pushed the improve-topic-creation-and-partition-update-before-starting-geo branch from 9f91e51 to a613da2 Compare August 20, 2025 14:28
@poorbarcode poorbarcode added this to the 4.2.0 milestone Sep 3, 2025
Copy link
Contributor

@poorbarcode poorbarcode left a comment

Choose a reason for hiding this comment

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

@nodece Thanks for driving this feature

}
// Set useFallbackForNonPIP344Brokers to true when mix of PIP-344 and non-PIP-344 brokers are used, it
// can still work.
return client.getLookup().getPartitionedTopicMetadata(baseTopicName, false, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we have pulsarAdmin object, can we use pulsar-admin.topics.getPartitionedTopicMetadataAsync here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I will refactor this logic.

.getClusterAsync(remoteCluster))
.thenAccept((clusterData) -> {
PulsarClient replicationClient = brokerService.getReplicationClient(remoteCluster, clusterData);
PulsarAdmin replicationAdmin = brokerService.getClusterPulsarAdmin(remoteCluster, clusterData);
Copy link
Contributor

Choose a reason for hiding this comment

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

brokerService.getClusterPulsarAdmin may throw a runtime exception. Should we consider it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I will move this logic from PersistentTopic to the replicator.

brokerService.getClusterPulsarAdmin may throw a runtime exception. Should we consider it?

If an exception is thrown, this future will be complete with an exception.


Awaitility.await().untilAsserted(() -> {
if (isPartitioned){
assertThat(admin2.topics().getPartitionedTopicList(ns)).contains(tp);
Copy link
Contributor

Choose a reason for hiding this comment

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

We'd better check that partitions are also created

}

@Test
public void testReplicatorWhenPartitionCountsDiffer() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good test

}
assertEquals(receive.getValue(), "msg-p2-1");
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also add another test?

  • Both clusters have different topic-auto-creation rules
  • The partitioned topic will by created by replicator at remote-side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants