You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ba...@apache.org on 2025/03/07 07:17:41 UTC

(pulsar) branch branch-3.0.10 created (now daa7e7498a9)

This is an automated email from the ASF dual-hosted git repository.

baodi pushed a change to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git


      at daa7e7498a9 Add branch-3.0.10 to workflow

This branch includes the following new commits:

     new c7ecd6a362b [improve][test] Upgrade Testcontainers to 1.20.4 and docker-java to 3.4.0 (#24003)
     new a71e39114b5 [improve][fn] Set default tenant and namespace for ListFunctions cmd (#23881)
     new 19337228332 [fix][admin] Verify is policies read only before revoke permissions on topic (#23730)
     new 384b9612d8f [improve][broker] Fix non-persistent system topic schema compatibility (#23286)
     new a4c6476842c [improve] [broker] Make the estimated entry size more accurate (#23931)
     new ee0ac0b214c [improve][ci] Upgrade Gradle Develocity Maven Extension to 1.23.1 (#24004)
     new dd8decaede6 [fix][broker] fix broker identifying incorrect stuck topic (#24006)
     new 515c6980d7c [fix][broker] Geo Replication lost messages or frequently fails due to Deduplication is not appropriate for Geo-Replication (#23697)
     new 2d6a03b5bd5 [fix][test] Fix flaky test OneWayReplicatorUsingGlobalZKTest.testConfigReplicationStartAt (#24011)
     new a496176da7f [fix][test]Fix flaky test V1_ProducerConsumerTest.testConcurrentConsumerReceiveWhileReconnect (#24019)
     new 07777309004 [fix][broker] Fix BucketDelayedDeliveryTracker thread safety (#24014)
     new 7909760b53f [improve][cli] Support additional msg metadata for V1 topic on peek message cmd (#23978)
     new e9cabbec851 [improve][ml] Use lock-free queue in InflightReadsLimiter since there's no concurrent access  (#23962)
     new 9b888374b66 Bump version to next snapshot version
     new daa7e7498a9 Add branch-3.0.10 to workflow

The 15 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(pulsar) 06/15: [improve][ci] Upgrade Gradle Develocity Maven Extension to 1.23.1 (#24004)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit ee0ac0b214c81022d5d6fe7ab1fdb4dd1478d940
Author: Lari Hotari <lh...@users.noreply.github.com>
AuthorDate: Sat Feb 22 10:27:10 2025 +0200

    [improve][ci] Upgrade Gradle Develocity Maven Extension to 1.23.1 (#24004)
    
    (cherry picked from commit 35c9fec78917cc2e03247f9a447d8464c91e7878)
    (cherry picked from commit 49ca5d6dcaac8d804602388809d516354ad41554)
---
 .mvn/extensions.xml                                |  2 +-
 .../pulsar/metadata/BaseMetadataStoreTest.java     | 36 ++++++++++++++++------
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml
index 8ceede33b9c..22eaa6a1779 100644
--- a/.mvn/extensions.xml
+++ b/.mvn/extensions.xml
@@ -24,7 +24,7 @@
   <extension>
     <groupId>com.gradle</groupId>
     <artifactId>develocity-maven-extension</artifactId>
-    <version>1.22.2</version>
+    <version>1.23.1</version>
   </extension>
   <extension>
     <groupId>com.gradle</groupId>
diff --git a/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/BaseMetadataStoreTest.java b/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/BaseMetadataStoreTest.java
index c4bd1959acc..5282507d5c4 100644
--- a/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/BaseMetadataStoreTest.java
+++ b/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/BaseMetadataStoreTest.java
@@ -25,6 +25,7 @@ import io.etcd.jetcd.test.EtcdClusterExtension;
 import java.io.File;
 import java.net.URI;
 import java.util.Arrays;
+import java.util.Optional;
 import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.CompletionException;
@@ -128,11 +129,11 @@ public abstract class BaseMetadataStoreTest extends TestRetrySupport {
         // The new connection string won't be available to the test method unless a
         // Supplier<String> lambda is used for providing the value.
         return new Object[][]{
-                {"ZooKeeper", stringSupplier(() -> zksConnectionString)},
-                {"Memory", stringSupplier(() -> memoryConnectionString)},
-                {"RocksDB", stringSupplier(() -> rocksdbConnectionString)},
-                {"Etcd", stringSupplier(() -> "etcd:" + getEtcdClusterConnectString())},
-                {"MockZooKeeper", stringSupplier(() -> mockZkUrl)},
+                {"ZooKeeper", providerUrlSupplier(() -> zksConnectionString)},
+                {"Memory", providerUrlSupplier(() -> memoryConnectionString)},
+                {"RocksDB", providerUrlSupplier(() -> rocksdbConnectionString)},
+                {"Etcd", providerUrlSupplier(() -> "etcd:" + getEtcdClusterConnectString(), "etcd:...")},
+                {"MockZooKeeper", providerUrlSupplier(() -> mockZkUrl)},
         };
     }
 
@@ -165,16 +166,29 @@ public abstract class BaseMetadataStoreTest extends TestRetrySupport {
         return etcdCluster.clientEndpoints().stream().map(URI::toString).collect(Collectors.joining(","));
     }
 
-    public static Supplier<String> stringSupplier(Supplier<String> supplier) {
-        return new StringSupplier(supplier);
+    private static Supplier<String> providerUrlSupplier(Supplier<String> supplier) {
+        return new ProviderUrlSupplier(supplier);
+    }
+
+    // Use this method to provide a custom toString value for the Supplier<String>. Use this when Testcontainers is used
+    // so that a toString call doesn't eagerly trigger container initialization which could cause a deadlock
+    // with Gradle Develocity Maven Extension.
+    private static Supplier<String> providerUrlSupplier(Supplier<String> supplier, String toStringValue) {
+        return new ProviderUrlSupplier(supplier, Optional.ofNullable(toStringValue));
     }
 
     // Implements toString() so that the test name is more descriptive
-    private static class StringSupplier implements Supplier<String> {
+    private static class ProviderUrlSupplier implements Supplier<String> {
         private final Supplier<String> supplier;
+        private final Optional<String> toStringValue;
+
+        ProviderUrlSupplier(Supplier<String> supplier) {
+            this(supplier, Optional.empty());
+        }
 
-        public StringSupplier(Supplier<String> supplier) {
+        ProviderUrlSupplier(Supplier<String> supplier, Optional<String> toStringValue) {
             this.supplier = supplier;
+            this.toStringValue = toStringValue;
         }
 
         @Override
@@ -184,7 +198,9 @@ public abstract class BaseMetadataStoreTest extends TestRetrySupport {
 
         @Override
         public String toString() {
-            return get();
+            // toStringValue is used to prevent deadlocks which could occur if toString method call eagerly triggers
+            // Testcontainers initialization. This is the case when Gradle Develocity Maven Extension is used.
+            return toStringValue.orElseGet(this::get);
         }
     }
 


(pulsar) 07/15: [fix][broker] fix broker identifying incorrect stuck topic (#24006)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit dd8decaede636f8788bb2fb626563fa0f9c4e8aa
Author: Rajan Dhabalia <rd...@apache.org>
AuthorDate: Thu Feb 20 01:46:47 2025 -0800

    [fix][broker] fix broker identifying incorrect stuck topic (#24006)
    
    (cherry picked from commit 28f7845c93edc0dcbc068a71bec45ab4b3402d4e)
    (cherry picked from commit 95101f301421c047f32f0f2b44c2b5e92ca80562)
---
 .../persistent/PersistentDispatcherMultipleConsumers.java  |  2 +-
 .../PersistentDispatcherSingleActiveConsumer.java          |  4 ++--
 .../broker/service/persistent/PersistentTopicTest.java     | 14 +++++++++++---
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
index ae844b57844..245ccaf2ee3 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
@@ -1227,7 +1227,7 @@ public class PersistentDispatcherMultipleConsumers extends AbstractDispatcherMul
             return false;
         }
         // consider dispatch is stuck if : dispatcher has backlog, available-permits and there is no pending read
-        if (totalAvailablePermits > 0 && !havePendingReplayRead && !havePendingRead
+        if (isAtleastOneConsumerAvailable() && !havePendingReplayRead && !havePendingRead
                 && cursor.getNumberOfEntriesInBacklog(false) > 0) {
             log.warn("{}-{} Dispatcher is stuck and unblocking by issuing reads", topic.getName(), name);
             readMoreEntries();
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java
index a138fde7a72..e1b17044b9b 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java
@@ -600,9 +600,9 @@ public class PersistentDispatcherSingleActiveConsumer extends AbstractDispatcher
         if (consumer == null || cursor.checkAndUpdateReadPositionChanged()) {
             return false;
         }
-        int totalAvailablePermits = consumer.getAvailablePermits();
+        boolean isConsumerAvailable = !consumer.isBlocked() && consumer.getAvailablePermits() > 0;
         // consider dispatch is stuck if : dispatcher has backlog, available-permits and there is no pending read
-        if (totalAvailablePermits > 0 && !havePendingRead && cursor.getNumberOfEntriesInBacklog(false) > 0) {
+        if (isConsumerAvailable && !havePendingRead && cursor.getNumberOfEntriesInBacklog(false) > 0) {
             log.warn("{}-{} Dispatcher is stuck and unblocking by issuing reads", topic.getName(), name);
             readMoreEntries(consumer);
             return true;
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/PersistentTopicTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/PersistentTopicTest.java
index a1fded261d1..c2097762228 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/PersistentTopicTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/PersistentTopicTest.java
@@ -18,7 +18,8 @@
  */
 package org.apache.pulsar.broker.service.persistent;
 
-import static org.apache.pulsar.broker.stats.prometheus.PrometheusMetricsClient.Metric;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
 import static org.apache.pulsar.broker.stats.prometheus.PrometheusMetricsClient.parseMetrics;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
@@ -35,8 +36,6 @@ import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
 import java.io.ByteArrayOutputStream;
 import java.lang.reflect.Field;
 import java.nio.charset.StandardCharsets;
@@ -74,6 +73,7 @@ import org.apache.pulsar.broker.service.BrokerService;
 import org.apache.pulsar.broker.service.BrokerTestBase;
 import org.apache.pulsar.broker.service.Topic;
 import org.apache.pulsar.broker.service.TopicPoliciesService;
+import org.apache.pulsar.broker.stats.prometheus.PrometheusMetricsClient.Metric;
 import org.apache.pulsar.client.admin.PulsarAdminException;
 import org.apache.pulsar.client.api.Consumer;
 import org.apache.pulsar.client.api.Message;
@@ -102,6 +102,7 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
+
 @Slf4j
 @Test(groups = "broker")
 public class PersistentTopicTest extends BrokerTestBase {
@@ -216,6 +217,13 @@ public class PersistentTopicTest extends BrokerTestBase {
         assertNotNull(msg);
         msg = consumer2.receive(5, TimeUnit.SECONDS);
         assertNotNull(msg);
+
+        org.apache.pulsar.broker.service.Consumer sharedConsumer = sharedDispatcher.getConsumers().get(0);
+        Field blockField = org.apache.pulsar.broker.service.Consumer.class.getDeclaredField("blockedConsumerOnUnackedMsgs");
+        blockField.setAccessible(true);
+        blockField.set(sharedConsumer, true);
+        producer.newMessage().value("test").eventTime(5).send();
+        assertFalse(sharedSub.checkAndUnblockIfStuck());
     }
 
     @Test


(pulsar) 11/15: [fix][broker] Fix BucketDelayedDeliveryTracker thread safety (#24014)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 077773090049c7dcd18546064c95b476c49e6f7f
Author: 道君 <da...@apache.org>
AuthorDate: Tue Feb 25 14:51:19 2025 +0800

    [fix][broker] Fix BucketDelayedDeliveryTracker thread safety (#24014)
    
    (cherry picked from commit a83dd86756bd540c8cc0991afcd3d2ba333603b7)
    (cherry picked from commit 4e39f705a9543975edc347f1b6d69224af559114)
---
 .../pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java
index c23bc17c303..65a92dcd8b9 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java
@@ -754,7 +754,7 @@ public class BucketDelayedDeliveryTracker extends AbstractDelayedDeliveryTracker
                 .orElse(false);
     }
 
-    public boolean containsMessage(long ledgerId, long entryId) {
+    public synchronized boolean containsMessage(long ledgerId, long entryId) {
         if (lastMutableBucket.containsMessage(ledgerId, entryId)) {
             return true;
         }


(pulsar) 03/15: [fix][admin] Verify is policies read only before revoke permissions on topic (#23730)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 1933722833227de5b0a4c65a38ecb3f719bf3048
Author: 道君 <da...@apache.org>
AuthorDate: Tue Dec 17 11:38:13 2024 +0800

    [fix][admin] Verify is policies read only before revoke permissions on topic (#23730)
    
    (cherry picked from commit 069cc3db7c741a7b1fc64c79733ada847dca873e)
    (cherry picked from commit 7df87f0cb60f021dd2fd0592d4ab6cd8873c9fb8)
---
 .../broker/admin/impl/PersistentTopicsBase.java    |  2 +-
 .../pulsar/broker/admin/PersistentTopicsTest.java  | 30 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
index 08fe12178a8..8833d0c70cb 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
@@ -365,7 +365,7 @@ public class PersistentTopicsBase extends AdminResource {
         // This operation should be reading from zookeeper and it should be allowed without having admin privileges
         CompletableFuture<Void> validateAccessForTenantCf =
                 validateAdminAccessForTenantAsync(namespaceName.getTenant())
-                .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync());
+                        .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync());
 
         var checkIfTopicExists = !pulsar().getConfiguration().isAllowAclChangesOnNonExistentTopics();
         if (checkIfTopicExists) {
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
index a5063802cfe..f4a9d7c0643 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
@@ -1021,6 +1021,36 @@ public class PersistentTopicsTest extends MockedPulsarServiceBaseTest {
         }
     }
 
+    @Test
+    public void testRevokePartitionedTopicWithReadonlyPolicies() throws Exception {
+        final String partitionedTopicName = "testRevokePartitionedTopicWithReadonlyPolicies-topic";
+        final int numPartitions = 5;
+        AsyncResponse response = mock(AsyncResponse.class);
+        ArgumentCaptor<Response> responseCaptor = ArgumentCaptor.forClass(Response.class);
+        persistentTopics.createPartitionedTopic(
+                response, testTenant, testNamespace, partitionedTopicName, numPartitions, true);
+        verify(response, timeout(5000).times(1)).resume(responseCaptor.capture());
+        Assert.assertEquals(responseCaptor.getValue().getStatus(), Response.Status.NO_CONTENT.getStatusCode());
+        String role = "role";
+        Set<AuthAction> expectActions = new HashSet<>();
+        expectActions.add(AuthAction.produce);
+        response = mock(AsyncResponse.class);
+        responseCaptor = ArgumentCaptor.forClass(Response.class);
+        persistentTopics.grantPermissionsOnTopic(response, testTenant, testNamespace, partitionedTopicName, role,
+                expectActions);
+        verify(response, timeout(5000).times(1)).resume(responseCaptor.capture());
+        Assert.assertEquals(responseCaptor.getValue().getStatus(), Response.Status.NO_CONTENT.getStatusCode());
+        response = mock(AsyncResponse.class);
+        doReturn(CompletableFuture.failedFuture(
+                new RestException(Response.Status.FORBIDDEN,  "Broker is forbidden to do read-write operations"))
+        ).when(persistentTopics).validatePoliciesReadOnlyAccessAsync();
+        persistentTopics.revokePermissionsOnTopic(response, testTenant, testNamespace, partitionedTopicName, role);
+        ArgumentCaptor<RestException> exceptionCaptor = ArgumentCaptor.forClass(RestException.class);
+        verify(response, timeout(5000).times(1)).resume(exceptionCaptor.capture());
+        Assert.assertEquals(exceptionCaptor.getValue().getResponse().getStatus(),
+                Response.Status.FORBIDDEN.getStatusCode());
+    }
+
     @Test
     public void testTriggerCompactionTopic() {
         final String partitionTopicName = "test-part";


(pulsar) 12/15: [improve][cli] Support additional msg metadata for V1 topic on peek message cmd (#23978)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 7909760b53f8adcf9e76356b5eac4fbfc3cc16ff
Author: Rajan Dhabalia <rd...@apache.org>
AuthorDate: Mon Feb 24 22:52:08 2025 -0800

    [improve][cli] Support additional msg metadata for V1 topic on peek message cmd (#23978)
    
    (cherry picked from commit 626b211f91fd8d1e9821ae8e2b9b29520e72ac63)
    (cherry picked from commit 46ff9f6dbae30330ce1a0cb60cbd749c74a638aa)
---
 .../pulsar/admin/cli/CmdPersistentTopics.java      | 24 +-----
 .../org/apache/pulsar/admin/cli/CmdTopics.java     | 94 ++++++++++++----------
 2 files changed, 52 insertions(+), 66 deletions(-)

diff --git a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdPersistentTopics.java b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdPersistentTopics.java
index 3c1662d00a0..752594f21d1 100644
--- a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdPersistentTopics.java
+++ b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdPersistentTopics.java
@@ -19,6 +19,7 @@
 package org.apache.pulsar.admin.cli;
 
 import static org.apache.commons.lang3.StringUtils.isNotBlank;
+import static org.apache.pulsar.admin.cli.CmdTopics.printMessages;
 import com.beust.jcommander.Parameter;
 import com.beust.jcommander.ParameterException;
 import com.beust.jcommander.Parameters;
@@ -39,8 +40,6 @@ import org.apache.pulsar.client.admin.Topics;
 import org.apache.pulsar.client.api.Message;
 import org.apache.pulsar.client.api.MessageId;
 import org.apache.pulsar.client.cli.NoSplitter;
-import org.apache.pulsar.client.impl.BatchMessageIdImpl;
-import org.apache.pulsar.client.impl.MessageIdImpl;
 import org.apache.pulsar.common.util.RelativeTimeUtil;
 
 @Parameters(commandDescription = "Operations on persistent topics. The persistent-topics "
@@ -606,26 +605,7 @@ public class CmdPersistentTopics extends CmdBase {
         void run() throws PulsarAdminException {
             String persistentTopic = validatePersistentTopic(params);
             List<Message<byte[]>> messages = getPersistentTopics().peekMessages(persistentTopic, subName, numMessages);
-            int position = 0;
-            for (Message<byte[]> msg : messages) {
-                if (++position != 1) {
-                    System.out.println("-------------------------------------------------------------------------\n");
-                }
-                if (msg.getMessageId() instanceof BatchMessageIdImpl) {
-                    BatchMessageIdImpl msgId = (BatchMessageIdImpl) msg.getMessageId();
-                    System.out.println("Batch Message ID: " + msgId.getLedgerId() + ":" + msgId.getEntryId() + ":"
-                            + msgId.getBatchIndex());
-                } else {
-                    MessageIdImpl msgId = (MessageIdImpl) msg.getMessageId();
-                    System.out.println("Message ID: " + msgId.getLedgerId() + ":" + msgId.getEntryId());
-                }
-                if (msg.getProperties().size() > 0) {
-                    System.out.println("Properties:");
-                    print(msg.getProperties());
-                }
-                ByteBuf data = Unpooled.wrappedBuffer(msg.getData());
-                System.out.println(ByteBufUtil.prettyHexDump(data));
-            }
+            printMessages(messages, false, this);
         }
     }
 
diff --git a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
index 7ff4dcdadc9..aaa15a48223 100644
--- a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
+++ b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
@@ -1208,50 +1208,7 @@ public class CmdTopics extends CmdBase {
             String persistentTopic = validatePersistentTopic(params);
             List<Message<byte[]>> messages = getTopics().peekMessages(persistentTopic, subName, numMessages,
                     showServerMarker, transactionIsolationLevel);
-            int position = 0;
-            for (Message<byte[]> msg : messages) {
-                MessageImpl message = (MessageImpl) msg;
-                if (++position != 1) {
-                    System.out.println("-------------------------------------------------------------------------\n");
-                }
-                if (message.getMessageId() instanceof BatchMessageIdImpl) {
-                    BatchMessageIdImpl msgId = (BatchMessageIdImpl) message.getMessageId();
-                    System.out.println("Batch Message ID: " + msgId.getLedgerId() + ":" + msgId.getEntryId() + ":"
-                            + msgId.getBatchIndex());
-                } else {
-                    MessageIdImpl msgId = (MessageIdImpl) msg.getMessageId();
-                    System.out.println("Message ID: " + msgId.getLedgerId() + ":" + msgId.getEntryId());
-                }
-
-                System.out.println("Publish time: " + message.getPublishTime());
-                System.out.println("Event time: " + message.getEventTime());
-
-                if (message.getDeliverAtTime() != 0) {
-                    System.out.println("Deliver at time: " + message.getDeliverAtTime());
-                }
-                MessageMetadata msgMetaData = message.getMessageBuilder();
-                if (showServerMarker && msgMetaData.hasMarkerType()) {
-                    System.out.println("Marker Type: " + MarkerType.valueOf(msgMetaData.getMarkerType()));
-                }
-
-                if (message.getBrokerEntryMetadata() != null) {
-                    if (message.getBrokerEntryMetadata().hasBrokerTimestamp()) {
-                        System.out.println("Broker entry metadata timestamp: "
-                                + message.getBrokerEntryMetadata().getBrokerTimestamp());
-                    }
-                    if (message.getBrokerEntryMetadata().hasIndex()) {
-                        System.out.println("Broker entry metadata index: "
-                                + message.getBrokerEntryMetadata().getIndex());
-                    }
-                }
-
-                if (message.getProperties().size() > 0) {
-                    System.out.println("Properties:");
-                    print(msg.getProperties());
-                }
-                ByteBuf data = Unpooled.wrappedBuffer(msg.getData());
-                System.out.println(ByteBufUtil.prettyHexDump(data));
-            }
+            printMessages(messages, showServerMarker, this);
         }
     }
 
@@ -1470,6 +1427,55 @@ public class CmdTopics extends CmdBase {
         return null;
     }
 
+    public static void printMessages(List<Message<byte[]>> messages, boolean showServerMarker, CliCommand cli) {
+        if (messages == null) {
+            return;
+        }
+        int position = 0;
+        for (Message<byte[]> msg : messages) {
+            MessageImpl message = (MessageImpl) msg;
+            if (++position != 1) {
+                System.out.println("-------------------------------------------------------------------------\n");
+            }
+            if (message.getMessageId() instanceof BatchMessageIdImpl) {
+                BatchMessageIdImpl msgId = (BatchMessageIdImpl) message.getMessageId();
+                System.out.println("Batch Message ID: " + msgId.getLedgerId() + ":" + msgId.getEntryId() + ":"
+                        + msgId.getBatchIndex());
+            } else {
+                MessageIdImpl msgId = (MessageIdImpl) msg.getMessageId();
+                System.out.println("Message ID: " + msgId.getLedgerId() + ":" + msgId.getEntryId());
+            }
+
+            System.out.println("Publish time: " + message.getPublishTime());
+            System.out.println("Event time: " + message.getEventTime());
+
+            if (message.getDeliverAtTime() != 0) {
+                System.out.println("Deliver at time: " + message.getDeliverAtTime());
+            }
+            MessageMetadata msgMetaData = message.getMessageBuilder();
+            if (showServerMarker && msgMetaData.hasMarkerType()) {
+                System.out.println("Marker Type: " + MarkerType.valueOf(msgMetaData.getMarkerType()));
+            }
+
+            if (message.getBrokerEntryMetadata() != null) {
+                if (message.getBrokerEntryMetadata().hasBrokerTimestamp()) {
+                    System.out.println("Broker entry metadata timestamp: "
+                            + message.getBrokerEntryMetadata().getBrokerTimestamp());
+                }
+                if (message.getBrokerEntryMetadata().hasIndex()) {
+                    System.out.println("Broker entry metadata index: " + message.getBrokerEntryMetadata().getIndex());
+                }
+            }
+
+            if (message.getProperties().size() > 0) {
+                System.out.println("Properties:");
+                cli.print(msg.getProperties());
+            }
+            ByteBuf data = Unpooled.wrappedBuffer(msg.getData());
+            System.out.println(ByteBufUtil.prettyHexDump(data));
+        }
+    }
+
     @Parameters(commandDescription = "Trigger offload of data from a topic to long-term storage (e.g. Amazon S3)")
     private class Offload extends CliCommand {
         @Parameter(names = { "-s", "--size-threshold" },


(pulsar) 15/15: Add branch-3.0.10 to workflow

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit daa7e7498a91f6ed546d68a208708cff13fab21e
Author: Baodi Shi <ba...@apache.org>
AuthorDate: Fri Mar 7 15:17:23 2025 +0800

    Add branch-3.0.10 to workflow
---
 .github/workflows/pulsar-ci.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/pulsar-ci.yaml b/.github/workflows/pulsar-ci.yaml
index fbf035a91f1..b15d42af871 100644
--- a/.github/workflows/pulsar-ci.yaml
+++ b/.github/workflows/pulsar-ci.yaml
@@ -23,6 +23,7 @@ on:
     branches:
       - master
       - branch-3.0
+      - branch-3.0.10
   schedule:
     - cron: '0 12 * * *'
   workflow_dispatch:


(pulsar) 04/15: [improve][broker] Fix non-persistent system topic schema compatibility (#23286)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 384b9612d8f3faf494bf0246fc23366eaee5f5a4
Author: Kai Wang <kw...@apache.org>
AuthorDate: Wed Feb 19 21:41:07 2025 +0800

    [improve][broker] Fix non-persistent system topic schema compatibility (#23286)
    
    When upgrading broker version from `3.0.x` to `3.3.x` with `ExtensibleLoadManagerImpl` enabled, it will have an `Unable to read schema` exception. And the broker will fail to start. This issue is caused by https://github.com/apache/pulsar/pull/22055 .
    
    Add a new class `NonPersistentSystemTopic`, and it will use for system non-persistent topic.
    
    (cherry picked from commit 7dbd8a507fc07d4fd5dc813ad76ee8080afd43cb)
    (cherry picked from commit 1c86d2517354b357926fdd2bcd0bca1f5a586323)
---
 .../pulsar/broker/service/BrokerService.java       |  7 +++-
 .../nonpersistent/NonPersistentSystemTopic.java    | 32 +++++++++++++++++
 .../extensions/ExtensibleLoadManagerImplTest.java  | 42 ++++++++++++++++++++++
 3 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
index 2e03accb523..6d85e7513cc 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
@@ -120,6 +120,7 @@ import org.apache.pulsar.broker.service.BrokerServiceException.PersistenceExcept
 import org.apache.pulsar.broker.service.BrokerServiceException.ServiceUnitNotReadyException;
 import org.apache.pulsar.broker.service.TopicEventsListener.EventStage;
 import org.apache.pulsar.broker.service.TopicEventsListener.TopicEvent;
+import org.apache.pulsar.broker.service.nonpersistent.NonPersistentSystemTopic;
 import org.apache.pulsar.broker.service.nonpersistent.NonPersistentTopic;
 import org.apache.pulsar.broker.service.persistent.DispatchRateLimiter;
 import org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumers;
@@ -1345,7 +1346,11 @@ public class BrokerService implements Closeable {
         final long topicCreateTimeMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
         NonPersistentTopic nonPersistentTopic;
         try {
-            nonPersistentTopic = newTopic(topic, null, this, NonPersistentTopic.class);
+            if (isSystemTopic(topic)) {
+                nonPersistentTopic = new NonPersistentSystemTopic(topic, this);
+            } else {
+                nonPersistentTopic = newTopic(topic, null, this, NonPersistentTopic.class);
+            }
             nonPersistentTopic.setCreateFuture(topicFuture);
         } catch (Throwable e) {
             log.warn("Failed to create topic {}", topic, e);
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentSystemTopic.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentSystemTopic.java
new file mode 100644
index 00000000000..9b867c9a8b3
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentSystemTopic.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service.nonpersistent;
+
+import org.apache.pulsar.broker.service.BrokerService;
+
+public class NonPersistentSystemTopic extends NonPersistentTopic {
+    public NonPersistentSystemTopic(String topic, BrokerService brokerService) {
+        super(topic, brokerService);
+    }
+
+    @Override
+    public boolean isSystemTopic() {
+        return true;
+    }
+}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java
index 7608f7d021d..5f8966eab03 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java
@@ -73,6 +73,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 import lombok.Cleanup;
+import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.reflect.FieldUtils;
 import org.apache.commons.lang3.tuple.Pair;
@@ -94,6 +95,7 @@ import org.apache.pulsar.broker.loadbalance.extensions.models.SplitDecision;
 import org.apache.pulsar.broker.loadbalance.extensions.models.UnloadCounter;
 import org.apache.pulsar.broker.loadbalance.extensions.reporter.BrokerLoadDataReporter;
 import org.apache.pulsar.broker.loadbalance.extensions.scheduler.TransferShedder;
+import org.apache.pulsar.broker.loadbalance.extensions.store.LoadDataStoreFactory;
 import org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerImpl;
 import org.apache.pulsar.broker.lookup.LookupResult;
 import org.apache.pulsar.broker.namespace.LookupOptions;
@@ -101,6 +103,7 @@ import org.apache.pulsar.broker.namespace.NamespaceBundleOwnershipListener;
 import org.apache.pulsar.broker.namespace.NamespaceEphemeralData;
 import org.apache.pulsar.broker.namespace.NamespaceService;
 import org.apache.pulsar.broker.service.BrokerServiceException;
+import org.apache.pulsar.broker.service.nonpersistent.NonPersistentSystemTopic;
 import org.apache.pulsar.client.admin.PulsarAdminException;
 import org.apache.pulsar.client.api.Consumer;
 import org.apache.pulsar.client.api.Producer;
@@ -114,6 +117,7 @@ import org.apache.pulsar.common.naming.TopicVersion;
 import org.apache.pulsar.common.policies.data.BrokerAssignment;
 import org.apache.pulsar.common.policies.data.BundlesData;
 import org.apache.pulsar.common.policies.data.NamespaceOwnershipStatus;
+import org.apache.pulsar.common.policies.data.SchemaCompatibilityStrategy;
 import org.apache.pulsar.common.stats.Metrics;
 import org.apache.pulsar.common.util.FutureUtil;
 import org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats;
@@ -121,6 +125,7 @@ import org.apache.pulsar.policies.data.loadbalancer.ResourceUsage;
 import org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage;
 import org.awaitility.Awaitility;
 import org.mockito.MockedStatic;
+import org.testng.Assert;
 import org.testng.AssertJUnit;
 import org.testng.annotations.Test;
 
@@ -1469,6 +1474,43 @@ public class ExtensibleLoadManagerImplTest extends ExtensibleLoadManagerImplBase
                 });
     }
 
+    @Test
+    public void testSystemNonPersistentTopicSchemaCompatibility() throws Exception {
+        String topicName = ExtensibleLoadManagerImpl.BROKER_LOAD_DATA_STORE_TOPIC;
+        NonPersistentSystemTopic topic = new NonPersistentSystemTopic(topicName, pulsar.getBrokerService());
+        Assert.assertEquals(SchemaCompatibilityStrategy.ALWAYS_COMPATIBLE, topic.getSchemaCompatibilityStrategy());
+
+        var brokerLoadDataStore = LoadDataStoreFactory.create(pulsar, topicName, BrokerLoadDataV1.class);
+        brokerLoadDataStore.init();
+        brokerLoadDataStore.pushAsync("key", new BrokerLoadDataV1()).get();
+        Awaitility.await().until(() -> {
+            var data = brokerLoadDataStore.get("key");
+            return data.isPresent();
+        });
+        brokerLoadDataStore.pushAsync("key", null).get();
+        brokerLoadDataStore.close();
+    }
+
+    @Data
+    private static class BrokerLoadDataV1 {
+        private ResourceUsage cpu;
+        private ResourceUsage memory;
+        private ResourceUsage directMemory;
+        private ResourceUsage bandwidthIn;
+        private ResourceUsage bandwidthOut;
+        private double msgThroughputIn;
+        private double msgThroughputOut;
+        private double msgRateIn;
+        private double msgRateOut;
+        private int bundleCount;
+        private int topics;
+        private double maxResourceUsage;
+        private double weightedMaxEMA;
+        private double msgThroughputEMA;
+        private long updatedAt;
+        private long reportedAt;
+    }
+
     @Test(timeOut = 10 * 1000)
     public void unloadTimeoutCheckTest()
             throws Exception {


(pulsar) 01/15: [improve][test] Upgrade Testcontainers to 1.20.4 and docker-java to 3.4.0 (#24003)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit c7ecd6a362bbf235341554d9174d1afbad55c4bd
Author: Lari Hotari <lh...@users.noreply.github.com>
AuthorDate: Thu Feb 20 03:34:55 2025 +0200

    [improve][test] Upgrade Testcontainers to 1.20.4 and docker-java to 3.4.0 (#24003)
    
    (cherry picked from commit 1c6aa7cdb04f1ad9625a3292897e3236a574cc86)
    (cherry picked from commit eaa4a7bf49d838a8ca859df65853bbdadde7860d)
---
 pom.xml | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 40b822dffbf..9a01ee522cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -259,12 +259,11 @@ flexible messaging model and an intuitive client API.</description>
     <failsafe.version>3.3.2</failsafe.version>
 
     <!-- test dependencies -->
-    <testcontainers.version>1.18.3</testcontainers.version>
+    <testcontainers.version>1.20.4</testcontainers.version>
+    <!-- Set docker-java.version to the version of docker-java used in org.testcontainers:testcontainers pom -->
+    <docker-java.version>3.4.0</docker-java.version>
     <hamcrest.version>2.2</hamcrest.version>
     <restassured.version>5.4.0</restassured.version>
-
-    <!-- Set docker-java.version to the version of docker-java used in Testcontainers -->
-    <docker-java.version>3.3.0</docker-java.version>
     <kerby.version>1.1.1</kerby.version>
     <testng.version>7.7.1</testng.version>
     <mockito.version>3.12.4</mockito.version>


(pulsar) 08/15: [fix][broker] Geo Replication lost messages or frequently fails due to Deduplication is not appropriate for Geo-Replication (#23697)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 515c6980d7c131003496559f348a591596bb160e
Author: fengyubiao <yu...@streamnative.io>
AuthorDate: Fri Feb 21 12:30:22 2025 +0800

    [fix][broker] Geo Replication lost messages or frequently fails due to Deduplication is not appropriate for Geo-Replication (#23697)
    
    (cherry picked from commit 4ac4f3c91bfdb7307c642fcbd35040015b5a8dd6)
    (cherry picked from commit 307b5c94ee552d7beba3f12e9088bdf340f4924f)
---
 .../pulsar/broker/service/AbstractReplicator.java  |   1 +
 .../org/apache/pulsar/broker/service/Producer.java |  82 +-
 .../apache/pulsar/broker/service/ServerCnx.java    |   2 +
 .../org/apache/pulsar/broker/service/Topic.java    |   4 +
 .../apache/pulsar/broker/service/TransportCnx.java |   8 +
 .../persistent/GeoPersistentReplicator.java        |   7 +
 .../service/persistent/MessageDeduplication.java   | 201 ++++-
 .../service/persistent/ShadowReplicator.java       |   4 +
 .../broker/BrokerMessageDeduplicationTest.java     |  17 +-
 .../service/OneWayReplicatorDeduplicationTest.java | 932 +++++++++++++++++++++
 .../pulsar/broker/service/ReplicatorTest.java      |   6 +-
 .../org/apache/pulsar/client/impl/ClientCnx.java   |  31 +-
 .../client/impl/GeoReplicationProducerImpl.java    | 249 ++++++
 .../apache/pulsar/client/impl/ProducerImpl.java    |  24 +-
 .../pulsar/client/impl/PulsarClientImpl.java       |   4 +
 .../impl/conf/ProducerConfigurationData.java       |   2 +
 .../apache/pulsar/common/protocol/Commands.java    |  13 +-
 .../org/apache/pulsar/common/protocol/Markers.java |  11 +
 pulsar-common/src/main/proto/PulsarApi.proto       |   1 +
 19 files changed, 1552 insertions(+), 47 deletions(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractReplicator.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractReplicator.java
index 86d19817da7..9677ed52e3c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractReplicator.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractReplicator.java
@@ -176,6 +176,7 @@ public abstract class AbstractReplicator implements Replicator {
         prepareCreateProducer().thenCompose(ignore -> {
             ProducerBuilderImpl builderImpl = (ProducerBuilderImpl) producerBuilder;
             builderImpl.getConf().setNonPartitionedTopicExpected(true);
+            builderImpl.getConf().setReplProducer(true);
             return producerBuilder.createAsync().thenAccept(producer -> {
                 setProducerAndTriggerReadEntries(producer);
             });
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Producer.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Producer.java
index b2953790d48..482256fc174 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Producer.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Producer.java
@@ -20,6 +20,8 @@ package org.apache.pulsar.broker.service;
 
 import static com.scurrilous.circe.checksum.Crc32cIntChecksum.computeChecksum;
 import static org.apache.pulsar.broker.service.AbstractReplicator.REPL_PRODUCER_NAME_DELIMITER;
+import static org.apache.pulsar.client.impl.GeoReplicationProducerImpl.MSG_PROP_IS_REPL_MARKER;
+import static org.apache.pulsar.client.impl.GeoReplicationProducerImpl.MSG_PROP_REPL_SOURCE_POSITION;
 import static org.apache.pulsar.common.protocol.Commands.hasChecksum;
 import static org.apache.pulsar.common.protocol.Commands.readChecksum;
 import com.google.common.annotations.VisibleForTesting;
@@ -87,6 +89,7 @@ public class Producer {
 
     private final PublisherStatsImpl stats;
     private final boolean isRemote;
+    private final boolean isRemoteOrShadow;
     private final String remoteCluster;
     private final boolean isNonPersistentTopic;
     private final boolean isShadowTopic;
@@ -151,6 +154,7 @@ public class Producer {
 
         String replicatorPrefix = serviceConf.getReplicatorPrefix() + ".";
         this.isRemote = producerName.startsWith(replicatorPrefix);
+        this.isRemoteOrShadow = isRemoteOrShadow(producerName, serviceConf.getReplicatorPrefix());
         this.remoteCluster = parseRemoteClusterName(producerName, isRemote, replicatorPrefix);
 
         this.isEncrypted = isEncrypted;
@@ -162,6 +166,13 @@ public class Producer {
         this.brokerInterceptor = cnx.getBrokerService().getInterceptor();
     }
 
+    /**
+     * Difference with "isRemote" is whether the prefix string is end with a dot.
+     */
+    public static boolean isRemoteOrShadow(String producerName, String replicatorPrefix) {
+        return producerName != null && producerName.startsWith(replicatorPrefix);
+    }
+
     /**
      * Producer name for replicator is in format.
      * "replicatorPrefix.localCluster" (old)
@@ -270,11 +281,16 @@ public class Producer {
         return true;
     }
 
+    private boolean isSupportsReplDedupByLidAndEid() {
+        // Non-Persistent topic does not have ledger id or entry id, so it does not support.
+        return cnx.isClientSupportsReplDedupByLidAndEid() && topic.isPersistent();
+    }
+
     private void publishMessageToTopic(ByteBuf headersAndPayload, long sequenceId, long batchSize, boolean isChunked,
                                        boolean isMarker, Position position) {
         MessagePublishContext messagePublishContext =
                 MessagePublishContext.get(this, sequenceId, msgIn, headersAndPayload.readableBytes(),
-                        batchSize, isChunked, System.nanoTime(), isMarker, position);
+                        batchSize, isChunked, System.nanoTime(), isMarker, position, isSupportsReplDedupByLidAndEid());
         if (brokerInterceptor != null) {
             brokerInterceptor
                     .onMessagePublish(this, headersAndPayload, messagePublishContext);
@@ -286,7 +302,7 @@ public class Producer {
                                        long batchSize, boolean isChunked, boolean isMarker, Position position) {
         MessagePublishContext messagePublishContext = MessagePublishContext.get(this, lowestSequenceId,
                 highestSequenceId, msgIn, headersAndPayload.readableBytes(), batchSize,
-                isChunked, System.nanoTime(), isMarker, position);
+                isChunked, System.nanoTime(), isMarker, position, isSupportsReplDedupByLidAndEid());
         if (brokerInterceptor != null) {
             brokerInterceptor
                     .onMessagePublish(this, headersAndPayload, messagePublishContext);
@@ -382,6 +398,7 @@ public class Producer {
         private long batchSize;
         private boolean chunked;
         private boolean isMarker;
+        private boolean supportsReplDedupByLidAndEid;
 
         private long startTimeNs;
 
@@ -472,6 +489,11 @@ public class Producer {
             return originalSequenceId;
         }
 
+        @Override
+        public boolean supportsReplDedupByLidAndEid() {
+            return supportsReplDedupByLidAndEid;
+        }
+
         @Override
         public void setOriginalHighestSequenceId(long originalHighestSequenceId) {
             this.originalHighestSequenceId = originalHighestSequenceId;
@@ -539,8 +561,12 @@ public class Producer {
             // stats
             rateIn.recordMultipleEvents(batchSize, msgSize);
             producer.topic.recordAddLatency(System.nanoTime() - startTimeNs, TimeUnit.NANOSECONDS);
-            producer.cnx.getCommandSender().sendSendReceiptResponse(producer.producerId, sequenceId, highestSequenceId,
-                    ledgerId, entryId);
+            if (producer.isRemoteOrShadow && producer.isSupportsReplDedupByLidAndEid()) {
+                sendSendReceiptResponseRepl();
+            } else {
+                // Repl V1 is the same as normal for this handling.
+                sendSendReceiptResponseNormal();
+            }
             producer.cnx.completedSendOperation(producer.isNonPersistentTopic, msgSize);
             if (this.chunked) {
                 producer.chunkedMessageRate.recordEvent();
@@ -553,8 +579,46 @@ public class Producer {
             recycle();
         }
 
+        private void sendSendReceiptResponseRepl() {
+            // Case-1: is a repl marker.
+            boolean isReplMarker = getProperty(MSG_PROP_IS_REPL_MARKER) != null;
+            if (isReplMarker) {
+                producer.cnx.getCommandSender().sendSendReceiptResponse(producer.producerId, sequenceId, Long.MIN_VALUE,
+                        ledgerId, entryId);
+
+                return;
+            }
+            // Case-2: is a repl message.
+            Object positionPairObj = getProperty(MSG_PROP_REPL_SOURCE_POSITION);
+            if (positionPairObj == null || !(positionPairObj instanceof long[])
+                    || ((long[]) positionPairObj).length < 2) {
+                log.error("[{}] Message can not determine whether the message is duplicated due to the acquired"
+                                + " messages props were are invalid. producer={}. supportsReplDedupByLidAndEid: {},"
+                                + " sequence-id {}, prop-{}: not in expected format",
+                        producer.topic.getName(), producer.producerName,
+                        supportsReplDedupByLidAndEid(), getSequenceId(),
+                        MSG_PROP_REPL_SOURCE_POSITION);
+                producer.cnx.getCommandSender().sendSendError(producer.producerId,
+                        Math.max(highestSequenceId, sequenceId),
+                        ServerError.PersistenceError, "Message can not determine whether the message is"
+                                + " duplicated due to the acquired messages props were are invalid");
+                return;
+            }
+            long[] positionPair = (long[]) positionPairObj;
+            long replSequenceLId = positionPair[0];
+            long replSequenceEId = positionPair[1];
+            producer.cnx.getCommandSender().sendSendReceiptResponse(producer.producerId, replSequenceLId,
+                    replSequenceEId, ledgerId, entryId);
+        }
+
+        private void sendSendReceiptResponseNormal() {
+            producer.cnx.getCommandSender().sendSendReceiptResponse(producer.producerId, sequenceId, highestSequenceId,
+                    ledgerId, entryId);
+        }
+
         static MessagePublishContext get(Producer producer, long sequenceId, Rate rateIn, int msgSize,
-                long batchSize, boolean chunked, long startTimeNs, boolean isMarker, Position position) {
+                             long batchSize, boolean chunked, long startTimeNs, boolean isMarker, Position position,
+                             boolean supportsReplDedupByLidAndEid) {
             MessagePublishContext callback = RECYCLER.get();
             callback.producer = producer;
             callback.sequenceId = sequenceId;
@@ -566,6 +630,7 @@ public class Producer {
             callback.originalSequenceId = -1L;
             callback.startTimeNs = startTimeNs;
             callback.isMarker = isMarker;
+            callback.supportsReplDedupByLidAndEid = supportsReplDedupByLidAndEid;
             callback.ledgerId = position == null ? -1 : position.getLedgerId();
             callback.entryId = position == null ? -1 : position.getEntryId();
             if (callback.propertyMap != null) {
@@ -575,7 +640,8 @@ public class Producer {
         }
 
         static MessagePublishContext get(Producer producer, long lowestSequenceId, long highestSequenceId, Rate rateIn,
-                int msgSize, long batchSize, boolean chunked, long startTimeNs, boolean isMarker, Position position) {
+                int msgSize, long batchSize, boolean chunked, long startTimeNs, boolean isMarker, Position position,
+                boolean supportsReplDedupByLidAndEid) {
             MessagePublishContext callback = RECYCLER.get();
             callback.producer = producer;
             callback.sequenceId = lowestSequenceId;
@@ -588,6 +654,7 @@ public class Producer {
             callback.startTimeNs = startTimeNs;
             callback.chunked = chunked;
             callback.isMarker = isMarker;
+            callback.supportsReplDedupByLidAndEid = supportsReplDedupByLidAndEid;
             callback.ledgerId = position == null ? -1 : position.getLedgerId();
             callback.entryId = position == null ? -1 : position.getEntryId();
             if (callback.propertyMap != null) {
@@ -815,7 +882,8 @@ public class Producer {
         }
         MessagePublishContext messagePublishContext =
                 MessagePublishContext.get(this, sequenceId, highSequenceId, msgIn,
-                        headersAndPayload.readableBytes(), batchSize, isChunked, System.nanoTime(), isMarker, null);
+                        headersAndPayload.readableBytes(), batchSize, isChunked, System.nanoTime(), isMarker, null,
+                        cnx.isClientSupportsReplDedupByLidAndEid());
         if (brokerInterceptor != null) {
             brokerInterceptor
                     .onMessagePublish(this, headersAndPayload, messagePublishContext);
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
index beb3ad88c45..692d058ff63 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
@@ -64,6 +64,7 @@ import javax.naming.AuthenticationException;
 import javax.net.ssl.SSLSession;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response;
+import lombok.Getter;
 import org.apache.bookkeeper.mledger.AsyncCallbacks;
 import org.apache.bookkeeper.mledger.Entry;
 import org.apache.bookkeeper.mledger.ManagedLedgerException;
@@ -233,6 +234,7 @@ public class ServerCnx extends PulsarHandler implements TransportCnx {
 
     // Flag to manage throttling-rate by atomically enable/disable read-channel.
     private volatile boolean autoReadDisabledRateLimiting = false;
+    @Getter
     private FeatureFlags features;
 
     private PulsarCommandSender commandSender;
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java
index 2e961b793d8..2ec7a6650e4 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java
@@ -127,6 +127,10 @@ public interface Topic {
         default void setEntryTimestamp(long entryTimestamp) {
 
         }
+
+        default boolean supportsReplDedupByLidAndEid() {
+            return false;
+        }
     }
 
     CompletableFuture<Void> initialize();
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TransportCnx.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TransportCnx.java
index d267160652a..8e933ed7137 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TransportCnx.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TransportCnx.java
@@ -23,6 +23,7 @@ import io.netty.util.concurrent.Promise;
 import java.net.SocketAddress;
 import java.util.concurrent.CompletableFuture;
 import org.apache.pulsar.broker.authentication.AuthenticationDataSource;
+import org.apache.pulsar.common.api.proto.FeatureFlags;
 
 public interface TransportCnx {
 
@@ -88,4 +89,11 @@ public interface TransportCnx {
      * is null if the connection liveness check is disabled.
      */
     CompletableFuture<Boolean> checkConnectionLiveness();
+
+    FeatureFlags getFeatures();
+
+    default boolean isClientSupportsReplDedupByLidAndEid() {
+        return getFeatures() != null && getFeatures().hasSupportsReplDedupByLidAndEid()
+                && getFeatures().isSupportsReplDedupByLidAndEid();
+    }
 }
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/GeoPersistentReplicator.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/GeoPersistentReplicator.java
index 3390c3a2885..adcaab29cfa 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/GeoPersistentReplicator.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/GeoPersistentReplicator.java
@@ -18,6 +18,7 @@
  */
 package org.apache.pulsar.broker.service.persistent;
 
+import static org.apache.pulsar.client.impl.GeoReplicationProducerImpl.MSG_PROP_REPL_SOURCE_POSITION;
 import io.netty.buffer.ByteBuf;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
@@ -195,9 +196,15 @@ public class GeoPersistentReplicator extends PersistentReplicator {
                     msg.setSchemaInfoForReplicator(schemaFuture.get());
                     msg.getMessageBuilder().clearTxnidMostBits();
                     msg.getMessageBuilder().clearTxnidLeastBits();
+                    // Add props for sequence checking.
+                    msg.getMessageBuilder().addProperty().setKey(MSG_PROP_REPL_SOURCE_POSITION)
+                            .setValue(String.format("%s:%s", entry.getLedgerId(), entry.getEntryId()));
                     msgOut.recordEvent(headersAndPayload.readableBytes());
                     // Increment pending messages for messages produced locally
                     PENDING_MESSAGES_UPDATER.incrementAndGet(this);
+                    if (log.isDebugEnabled()) {
+                        log.debug("[{}] Publishing {}:{}", replicatorId, entry.getLedgerId(), entry.getEntryId());
+                    }
                     producer.sendAsync(msg, ProducerSendCallback.create(this, entry, msg));
                     atLeastOneMessageSentForReplication = true;
                 }
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/MessageDeduplication.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/MessageDeduplication.java
index 1715e09dc7b..bf482986ec9 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/MessageDeduplication.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/MessageDeduplication.java
@@ -18,6 +18,8 @@
  */
 package org.apache.pulsar.broker.service.persistent;
 
+import static org.apache.pulsar.client.impl.GeoReplicationProducerImpl.MSG_PROP_IS_REPL_MARKER;
+import static org.apache.pulsar.client.impl.GeoReplicationProducerImpl.MSG_PROP_REPL_SOURCE_POSITION;
 import com.google.common.annotations.VisibleForTesting;
 import io.netty.buffer.ByteBuf;
 import java.util.Iterator;
@@ -38,10 +40,14 @@ import org.apache.bookkeeper.mledger.ManagedLedger;
 import org.apache.bookkeeper.mledger.ManagedLedgerException;
 import org.apache.bookkeeper.mledger.Position;
 import org.apache.bookkeeper.mledger.impl.PositionImpl;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.service.Producer;
 import org.apache.pulsar.broker.service.Topic.PublishContext;
+import org.apache.pulsar.common.api.proto.KeyValue;
 import org.apache.pulsar.common.api.proto.MessageMetadata;
 import org.apache.pulsar.common.protocol.Commands;
+import org.apache.pulsar.common.protocol.Markers;
 import org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -330,27 +336,157 @@ public class MessageDeduplication {
      * @return true if the message should be published or false if it was recognized as a duplicate
      */
     public MessageDupStatus isDuplicate(PublishContext publishContext, ByteBuf headersAndPayload) {
+        setContextPropsIfRepl(publishContext, headersAndPayload);
         if (!isEnabled() || publishContext.isMarkerMessage()) {
             return MessageDupStatus.NotDup;
         }
+        if (Producer.isRemoteOrShadow(publishContext.getProducerName(), replicatorPrefix)) {
+            if (!publishContext.supportsReplDedupByLidAndEid()){
+                return isDuplicateReplV1(publishContext, headersAndPayload);
+            } else {
+                return isDuplicateReplV2(publishContext, headersAndPayload);
+            }
+        }
+        return isDuplicateNormal(publishContext, headersAndPayload, false);
+    }
+
+    public MessageDupStatus isDuplicateReplV1(PublishContext publishContext, ByteBuf headersAndPayload) {
+        // Message is coming from replication, we need to use the original producer name and sequence id
+        // for the purpose of deduplication and not rely on the "replicator" name.
+        int readerIndex = headersAndPayload.readerIndex();
+        MessageMetadata md = Commands.parseMessageMetadata(headersAndPayload);
+        headersAndPayload.readerIndex(readerIndex);
+
+        String producerName = md.getProducerName();
+        long sequenceId = md.getSequenceId();
+        long highestSequenceId = Math.max(md.getHighestSequenceId(), sequenceId);
+        publishContext.setOriginalProducerName(producerName);
+        publishContext.setOriginalSequenceId(sequenceId);
+        publishContext.setOriginalHighestSequenceId(highestSequenceId);
+        return isDuplicateNormal(publishContext, headersAndPayload, true);
+    }
+
+    private void setContextPropsIfRepl(PublishContext publishContext, ByteBuf headersAndPayload) {
+        // Case-1: is a replication marker.
+        if (publishContext.isMarkerMessage()) {
+            // Message is coming from replication, we need to use the replication's producer name, ledger id and entry
+            // id for the purpose of deduplication.
+            MessageMetadata md = Commands.peekMessageMetadata(headersAndPayload, "Check-Deduplicate", -1);
+            if (Markers.isReplicationMarker(md.getMarkerType())) {
+                publishContext.setProperty(MSG_PROP_IS_REPL_MARKER, "");
+            }
+            return;
+        }
+
+        // Case-2: is a replicated message.
+        if (Producer.isRemoteOrShadow(publishContext.getProducerName(), replicatorPrefix)) {
+            // Message is coming from replication, we need to use the replication's producer name, source cluster's
+            // ledger id and entry id for the purpose of deduplication.
+            int readerIndex = headersAndPayload.readerIndex();
+            MessageMetadata md = Commands.parseMessageMetadata(headersAndPayload);
+            headersAndPayload.readerIndex(readerIndex);
+
+            List<KeyValue> kvPairList = md.getPropertiesList();
+            for (KeyValue kvPair : kvPairList) {
+                if (kvPair.getKey().equals(MSG_PROP_REPL_SOURCE_POSITION)) {
+                    if (!kvPair.getValue().contains(":")) {
+                        log.warn("[{}] Unexpected {}: {}", publishContext.getProducerName(),
+                                MSG_PROP_REPL_SOURCE_POSITION,
+                                kvPair.getValue());
+                        break;
+                    }
+                    String[] ledgerIdAndEntryId = kvPair.getValue().split(":");
+                    if (ledgerIdAndEntryId.length != 2 || !StringUtils.isNumeric(ledgerIdAndEntryId[0])
+                            || !StringUtils.isNumeric(ledgerIdAndEntryId[1])) {
+                        log.warn("[{}] Unexpected {}: {}", publishContext.getProducerName(),
+                                MSG_PROP_REPL_SOURCE_POSITION,
+                                kvPair.getValue());
+                        break;
+                    }
+                    long[] positionPair = new long[]{Long.valueOf(ledgerIdAndEntryId[0]).longValue(),
+                            Long.valueOf(ledgerIdAndEntryId[1]).longValue()};
+                    publishContext.setProperty(MSG_PROP_REPL_SOURCE_POSITION, positionPair);
+                    break;
+                }
+            }
+        }
+    }
+
+    public MessageDupStatus isDuplicateReplV2(PublishContext publishContext, ByteBuf headersAndPayload) {
+        Object positionPairObj = publishContext.getProperty(MSG_PROP_REPL_SOURCE_POSITION);
+        if (positionPairObj == null || !(positionPairObj instanceof long[])) {
+            log.error("[{}] Message can not determine whether the message is duplicated due to the acquired messages"
+                            + " props were are invalid. producer={}. supportsReplDedupByLidAndEid: {}, sequence-id {},"
+                            + " prop-{}: not in expected format",
+                    topic.getName(), publishContext.getProducerName(),
+                    publishContext.supportsReplDedupByLidAndEid(), publishContext.getSequenceId(),
+                    MSG_PROP_REPL_SOURCE_POSITION);
+            return MessageDupStatus.Unknown;
+        }
+
+        long[] positionPair = (long[]) positionPairObj;
+        long replSequenceLId = positionPair[0];
+        long replSequenceEId = positionPair[1];
+
+        String lastSequenceLIdKey = publishContext.getProducerName() + "_LID";
+        String lastSequenceEIdKey = publishContext.getProducerName() + "_EID";
+        synchronized (highestSequencedPushed) {
+            Long lastSequenceLIdPushed = highestSequencedPushed.get(lastSequenceLIdKey);
+            Long lastSequenceEIdPushed = highestSequencedPushed.get(lastSequenceEIdKey);
+            if (lastSequenceLIdPushed != null && lastSequenceEIdPushed != null
+                && (replSequenceLId < lastSequenceLIdPushed.longValue()
+                        || (replSequenceLId == lastSequenceLIdPushed.longValue()
+                        && replSequenceEId <= lastSequenceEIdPushed.longValue()))) {
+                if (log.isDebugEnabled()) {
+                    log.debug("[{}] Message identified as duplicated producer={}. publishing {}:{}, latest publishing"
+                            + " in-progress {}:{}",
+                            topic.getName(), publishContext.getProducerName(), lastSequenceLIdPushed,
+                            lastSequenceEIdPushed, lastSequenceLIdPushed, lastSequenceEIdPushed);
+                }
+
+                // Also need to check sequence ids that has been persisted.
+                // If current message's seq id is smaller or equals to the
+                // "lastSequenceLIdPersisted:lastSequenceEIdPersisted" than its definitely a dup
+                // If current message's seq id is between "lastSequenceLIdPushed:lastSequenceEIdPushed" and
+                // "lastSequenceLIdPersisted:lastSequenceEIdPersisted", then we cannot be sure whether the message
+                // is a dup or not we should return an error to the producer for the latter case so that it can retry
+                // at a future time
+                Long lastSequenceLIdPersisted = highestSequencedPersisted.get(lastSequenceLIdKey);
+                Long lastSequenceEIdPersisted = highestSequencedPersisted.get(lastSequenceEIdKey);
+                if (log.isDebugEnabled()) {
+                    log.debug("[{}] Message identified as duplicated producer={}. publishing {}:{}, latest"
+                                    + " persisted {}:{}",
+                            topic.getName(), publishContext.getProducerName(), replSequenceLId,
+                            replSequenceEId, lastSequenceLIdPersisted, lastSequenceEIdPersisted);
+                }
+                if (lastSequenceLIdPersisted != null && lastSequenceEIdPersisted != null
+                    && (replSequenceLId < lastSequenceLIdPersisted.longValue()
+                        || (replSequenceLId == lastSequenceLIdPersisted.longValue()
+                            && replSequenceEId <= lastSequenceEIdPersisted))) {
+                    return MessageDupStatus.Dup;
+                } else {
+                    return MessageDupStatus.Unknown;
+                }
+            }
+            highestSequencedPushed.put(lastSequenceLIdKey, replSequenceLId);
+            highestSequencedPushed.put(lastSequenceEIdKey, replSequenceEId);
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("[{}] Message identified as non-duplicated producer={}. publishing {}:{}",
+                    topic.getName(), publishContext.getProducerName(), replSequenceLId, replSequenceEId);
+        }
+        return MessageDupStatus.NotDup;
+    }
 
+    public MessageDupStatus isDuplicateNormal(PublishContext publishContext, ByteBuf headersAndPayload,
+                                              boolean useOriginalProducerName) {
         String producerName = publishContext.getProducerName();
+        if (useOriginalProducerName) {
+            producerName = publishContext.getOriginalProducerName();
+        }
         long sequenceId = publishContext.getSequenceId();
         long highestSequenceId = Math.max(publishContext.getHighestSequenceId(), sequenceId);
         MessageMetadata md = null;
-        if (producerName.startsWith(replicatorPrefix)) {
-            // Message is coming from replication, we need to use the original producer name and sequence id
-            // for the purpose of deduplication and not rely on the "replicator" name.
-            int readerIndex = headersAndPayload.readerIndex();
-            md = Commands.parseMessageMetadata(headersAndPayload);
-            producerName = md.getProducerName();
-            sequenceId = md.getSequenceId();
-            highestSequenceId = Math.max(md.getHighestSequenceId(), sequenceId);
-            publishContext.setOriginalProducerName(producerName);
-            publishContext.setOriginalSequenceId(sequenceId);
-            publishContext.setOriginalHighestSequenceId(highestSequenceId);
-            headersAndPayload.readerIndex(readerIndex);
-        }
         long chunkID = -1;
         long totalChunk = -1;
         if (publishContext.isChunked()) {
@@ -408,7 +544,37 @@ public class MessageDeduplication {
         if (!isEnabled() || publishContext.isMarkerMessage()) {
             return;
         }
+        if (publishContext.getProducerName().startsWith(replicatorPrefix)
+                && publishContext.supportsReplDedupByLidAndEid()) {
+            recordMessagePersistedRepl(publishContext, position);
+        } else {
+            recordMessagePersistedNormal(publishContext, position);
+        }
+    }
+
+    public void recordMessagePersistedRepl(PublishContext publishContext, Position position) {
+        Object positionPairObj = publishContext.getProperty(MSG_PROP_REPL_SOURCE_POSITION);
+        if (positionPairObj == null || !(positionPairObj instanceof long[])) {
+            log.error("[{}] Can not persist highest sequence-id due to the acquired messages"
+                            + " props are invalid. producer={}. supportsReplDedupByLidAndEid: {}, sequence-id {},"
+                            + " prop-{}: not in expected format",
+                    topic.getName(), publishContext.getProducerName(),
+                    publishContext.supportsReplDedupByLidAndEid(), publishContext.getSequenceId(),
+                    MSG_PROP_REPL_SOURCE_POSITION);
+            recordMessagePersistedNormal(publishContext, position);
+            return;
+        }
+        long[] positionPair = (long[]) positionPairObj;
+        long replSequenceLId = positionPair[0];
+        long replSequenceEId = positionPair[1];
+        String lastSequenceLIdKey = publishContext.getProducerName() + "_LID";
+        String lastSequenceEIdKey = publishContext.getProducerName() + "_EID";
+        highestSequencedPersisted.put(lastSequenceLIdKey, replSequenceLId);
+        highestSequencedPersisted.put(lastSequenceEIdKey, replSequenceEId);
+        increaseSnapshotCounterAndTakeSnapshotIfNeeded(position);
+    }
 
+    public void recordMessagePersistedNormal(PublishContext publishContext, Position position) {
         String producerName = publishContext.getProducerName();
         long sequenceId = publishContext.getSequenceId();
         long highestSequenceId = publishContext.getHighestSequenceId();
@@ -422,9 +588,18 @@ public class MessageDeduplication {
         if (isLastChunk == null || isLastChunk) {
             highestSequencedPersisted.put(producerName, Math.max(highestSequenceId, sequenceId));
         }
+        increaseSnapshotCounterAndTakeSnapshotIfNeeded(position);
+    }
+
+    private void increaseSnapshotCounterAndTakeSnapshotIfNeeded(Position position) {
         if (++snapshotCounter >= snapshotInterval) {
             snapshotCounter = 0;
             takeSnapshot(position);
+        } else {
+            if (log.isDebugEnabled()) {
+                log.debug("[{}] Waiting for sequence-id snapshot {}/{}", topic.getName(), snapshotCounter,
+                        snapshotInterval);
+            }
         }
     }
 
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/ShadowReplicator.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/ShadowReplicator.java
index b48f748bf5d..ab465d1dcc4 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/ShadowReplicator.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/ShadowReplicator.java
@@ -19,6 +19,7 @@
 package org.apache.pulsar.broker.service.persistent;
 
 
+import static org.apache.pulsar.client.impl.GeoReplicationProducerImpl.MSG_PROP_REPL_SOURCE_POSITION;
 import io.netty.buffer.ByteBuf;
 import java.util.List;
 import lombok.extern.slf4j.Slf4j;
@@ -96,6 +97,9 @@ public class ShadowReplicator extends PersistentReplicator {
                 msg.setReplicatedFrom(localCluster);
 
                 msg.setMessageId(new MessageIdImpl(entry.getLedgerId(), entry.getEntryId(), -1));
+                // Add props for sequence checking.
+                msg.getMessageBuilder().addProperty().setKey(MSG_PROP_REPL_SOURCE_POSITION)
+                        .setValue(String.format("%s:%s", entry.getLedgerId(), entry.getEntryId()));
 
                 headersAndPayload.retain();
 
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/BrokerMessageDeduplicationTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/BrokerMessageDeduplicationTest.java
index 50f8ac95944..eb110927221 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/BrokerMessageDeduplicationTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/BrokerMessageDeduplicationTest.java
@@ -24,10 +24,14 @@ import static org.mockito.Mockito.spy;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
 import org.apache.bookkeeper.mledger.ManagedLedger;
 import org.apache.pulsar.broker.service.Topic;
 import org.apache.pulsar.broker.service.persistent.MessageDeduplication;
 import org.apache.pulsar.broker.service.persistent.PersistentTopic;
+import org.apache.pulsar.common.api.proto.MarkerType;
+import org.apache.pulsar.common.api.proto.MessageMetadata;
 import org.testng.annotations.Test;
 
 public class BrokerMessageDeduplicationTest {
@@ -42,7 +46,18 @@ public class BrokerMessageDeduplicationTest {
         doReturn(true).when(deduplication).isEnabled();
         Topic.PublishContext context = mock(Topic.PublishContext.class);
         doReturn(true).when(context).isMarkerMessage();
-        MessageDeduplication.MessageDupStatus status = deduplication.isDuplicate(context, null);
+
+        MessageMetadata msgMetadata = new MessageMetadata();
+        msgMetadata.setMarkerType(MarkerType.TXN_ABORT_VALUE);
+        msgMetadata.setProducerName("p1");
+        msgMetadata.setSequenceId(0);
+        msgMetadata.setPublishTime(System.currentTimeMillis());
+        byte[] metadataData = msgMetadata.toByteArray();
+        ByteBuf byteBuf = UnpooledByteBufAllocator.DEFAULT.heapBuffer(metadataData.length + 4);
+        byteBuf.writeInt(metadataData.length);
+        byteBuf.writeBytes(metadataData);
+
+        MessageDeduplication.MessageDupStatus status = deduplication.isDuplicate(context, byteBuf);
         assertEquals(status, MessageDeduplication.MessageDupStatus.NotDup);
     }
 
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorDeduplicationTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorDeduplicationTest.java
new file mode 100644
index 00000000000..a95a8f0ddfa
--- /dev/null
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorDeduplicationTest.java
@@ -0,0 +1,932 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.spy;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelPromise;
+import io.vertx.core.impl.ConcurrentHashSet;
+import java.lang.reflect.Field;
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.bookkeeper.mledger.ManagedCursor;
+import org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pulsar.broker.BrokerTestUtil;
+import org.apache.pulsar.broker.PulsarService;
+import org.apache.pulsar.broker.ServiceConfiguration;
+import org.apache.pulsar.broker.service.persistent.MessageDeduplication;
+import org.apache.pulsar.broker.service.persistent.PersistentTopic;
+import org.apache.pulsar.broker.service.schema.SchemaRegistryService;
+import org.apache.pulsar.client.api.Consumer;
+import org.apache.pulsar.client.api.InjectedClientCnxClientBuilder;
+import org.apache.pulsar.client.api.Message;
+import org.apache.pulsar.client.api.MessageId;
+import org.apache.pulsar.client.api.MessageIdAdv;
+import org.apache.pulsar.client.api.Producer;
+import org.apache.pulsar.client.api.PulsarClient;
+import org.apache.pulsar.client.api.PulsarClientException;
+import org.apache.pulsar.client.api.Schema;
+import org.apache.pulsar.client.api.schema.GenericRecord;
+import org.apache.pulsar.client.impl.ClientBuilderImpl;
+import org.apache.pulsar.client.impl.ClientCnx;
+import org.apache.pulsar.client.impl.ProducerImpl;
+import org.apache.pulsar.client.impl.PulsarClientImpl;
+import org.apache.pulsar.common.api.AuthData;
+import org.apache.pulsar.common.api.proto.BaseCommand;
+import org.apache.pulsar.common.api.proto.CommandGetOrCreateSchemaResponse;
+import org.apache.pulsar.common.api.proto.CommandGetSchemaResponse;
+import org.apache.pulsar.common.policies.data.SchemaCompatibilityStrategy;
+import org.apache.pulsar.common.protocol.ByteBufPair;
+import org.apache.pulsar.common.protocol.Commands;
+import org.apache.pulsar.common.protocol.schema.SchemaData;
+import org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble;
+import org.apache.pulsar.zookeeper.ZookeeperServerTest;
+import org.awaitility.Awaitility;
+import org.awaitility.reflect.WhiteboxImpl;
+import org.mockito.stubbing.Answer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+@Slf4j
+@Test(groups = "broker")
+public class OneWayReplicatorDeduplicationTest extends OneWayReplicatorTestBase {
+
+    static final ObjectMapper JACKSON = new ObjectMapper();
+
+    @Override
+    @BeforeClass(alwaysRun = true, timeOut = 300000)
+    public void setup() throws Exception {
+        super.setup();
+        waitInternalClientCreated();
+    }
+
+    @Override
+    @AfterClass(alwaysRun = true, timeOut = 300000)
+    public void cleanup() throws Exception {
+        super.cleanup();
+    }
+
+    @Override
+    protected void setConfigDefaults(ServiceConfiguration config, String clusterName,
+                                     LocalBookkeeperEnsemble bookkeeperEnsemble, ZookeeperServerTest brokerConfigZk) {
+        super.setConfigDefaults(config, clusterName, bookkeeperEnsemble, brokerConfigZk);
+        // For check whether deduplication snapshot has done.
+        config.setBrokerDeduplicationEntriesInterval(10);
+        config.setReplicationStartAt("earliest");
+        // To cover more cases, write more than one ledger.
+        config.setManagedLedgerMaxEntriesPerLedger(100);
+        config.setManagedLedgerMinLedgerRolloverTimeMinutes(0);
+        config.setManagedLedgerMaxLedgerRolloverTimeMinutes(1);
+    }
+
+    protected void waitReplicatorStopped(String topicName) {
+        Awaitility.await().untilAsserted(() -> {
+            Optional<Topic> topicOptional2 = pulsar2.getBrokerService().getTopic(topicName, false).get();
+            assertTrue(topicOptional2.isPresent());
+            PersistentTopic persistentTopic2 = (PersistentTopic) topicOptional2.get();
+            assertTrue(persistentTopic2.getProducers().isEmpty());
+            Optional<Topic> topicOptional1 = pulsar2.getBrokerService().getTopic(topicName, false).get();
+            assertTrue(topicOptional1.isPresent());
+            PersistentTopic persistentTopic1 = (PersistentTopic) topicOptional2.get();
+            assertTrue(persistentTopic1.getReplicators().isEmpty()
+                    || !persistentTopic1.getReplicators().get(cluster2).isConnected());
+        });
+    }
+
+    protected void waitInternalClientCreated() throws Exception {
+        // Wait for the internal client created.
+        final String topicNameTriggerInternalClientCreate =
+                BrokerTestUtil.newUniqueName("persistent://" + replicatedNamespace + "/tp_");
+        admin1.topics().createNonPartitionedTopic(topicNameTriggerInternalClientCreate);
+        waitReplicatorStarted(topicNameTriggerInternalClientCreate);
+        cleanupTopics(() -> {
+            admin1.topics().delete(topicNameTriggerInternalClientCreate);
+            admin2.topics().delete(topicNameTriggerInternalClientCreate);
+        });
+    }
+
+    protected Runnable injectReplicatorClientCnx(
+            InjectedClientCnxClientBuilder.ClientCnxFactory clientCnxFactory) throws Exception {
+        String cluster2 = pulsar2.getConfig().getClusterName();
+        BrokerService brokerService = pulsar1.getBrokerService();
+        ClientBuilderImpl clientBuilder2 = (ClientBuilderImpl) PulsarClient.builder().serviceUrl(url2.toString());
+
+        // Inject spy client.
+        final var replicationClients = brokerService.getReplicationClients();
+        PulsarClientImpl internalClient = (PulsarClientImpl) replicationClients.get(cluster2);
+        PulsarClientImpl injectedClient = InjectedClientCnxClientBuilder.create(clientBuilder2, clientCnxFactory);
+        assertTrue(replicationClients.remove(cluster2, internalClient));
+        assertNull(replicationClients.putIfAbsent(cluster2, injectedClient));
+
+        // Return a cleanup injection task;
+        return () -> {
+            assertTrue(replicationClients.remove(cluster2, injectedClient));
+            assertNull(replicationClients.putIfAbsent(cluster2, internalClient));
+            injectedClient.closeAsync();
+        };
+    }
+
+    @DataProvider(name = "deduplicationArgs")
+    public Object[][] deduplicationArgs() {
+        return new Object[][] {
+            {true/* inject repeated publishing*/, 1/* repeated messages window */,
+                    true /* supportsReplDedupByLidAndEid */, false/* multi schemas */},
+            {true/* inject repeated publishing*/, 2/* repeated messages window */,
+                    true /* supportsReplDedupByLidAndEid */, false/* multi schemas */},
+            {true/* inject repeated publishing*/, 3/* repeated messages window */,
+                    true /* supportsReplDedupByLidAndEid */, false/* multi schemas */},
+            {true/* inject repeated publishing*/, 4/* repeated messages window */,
+                    true /* supportsReplDedupByLidAndEid */, false/* multi schemas */},
+            {true/* inject repeated publishing*/, 5/* repeated messages window */,
+                    true /* supportsReplDedupByLidAndEid */, false/* multi schemas */},
+            {true/* inject repeated publishing*/, 10/* repeated messages window */,
+                    true /* supportsReplDedupByLidAndEid */, false/* multi schemas */},
+            // ===== multi schema
+            {true/* inject repeated publishing*/, 1/* repeated messages window */,
+                    true /* supportsReplDedupByLidAndEid */, true/* multi schemas */},
+            {true/* inject repeated publishing*/, 2/* repeated messages window */,
+                    true /* supportsReplDedupByLidAndEid */, true/* multi schemas */},
+            {true/* inject repeated publishing*/, 3/* repeated messages window */,
+                    true /* supportsReplDedupByLidAndEid */, true/* multi schemas */},
+            {true/* inject repeated publishing*/, 4/* repeated messages window */,
+                    true /* supportsReplDedupByLidAndEid */, true/* multi schemas */},
+            {true/* inject repeated publishing*/, 5/* repeated messages window */,
+                    true /* supportsReplDedupByLidAndEid */, true/* multi schemas */},
+            {true/* inject repeated publishing*/, 10/* repeated messages window */,
+                    true /* supportsReplDedupByLidAndEid */, true/* multi schemas */},
+            // ===== Compatability "source-cluster: old, target-cluster: new".
+            {false/* inject repeated publishing*/, 0/* repeated messages window */,
+                    false /* supportsReplDedupByLidAndEid */, false/* multi schemas */},
+            {false/* inject repeated publishing*/, 0/* repeated messages window */,
+                    false /* supportsReplDedupByLidAndEid */, true/* multi schemas */},
+            {true/* inject repeated publishing*/, 3/* repeated messages window */,
+                    false /* supportsReplDedupByLidAndEid */, true/* multi schemas */},
+        };
+    }
+
+    // TODO
+    //  - Review the code to confirm that multi source-brokers can work when the source topic switch.
+    @Test(timeOut = 360 * 1000, dataProvider = "deduplicationArgs")
+    public void testDeduplication(final boolean injectRepeatedPublish, final int repeatedMessagesWindow,
+                                  final boolean supportsReplDedupByLidAndEid, boolean multiSchemas) throws Exception {
+        // 0. Inject a mechanism that duplicate all Send-Command for the replicator.
+        final List<ByteBufPair> duplicatedMsgs = new ArrayList<>();
+        Runnable taskToClearInjection = injectReplicatorClientCnx(
+            (conf, eventLoopGroup) -> new ClientCnx(conf, eventLoopGroup) {
+
+                @Override
+                protected ByteBuf newConnectCommand() throws Exception {
+                    if (supportsReplDedupByLidAndEid) {
+                        return super.newConnectCommand();
+                    }
+                    authenticationDataProvider = authentication.getAuthData(remoteHostName);
+                    AuthData authData = authenticationDataProvider.authenticate(AuthData.INIT_AUTH_DATA);
+                    BaseCommand cmd = Commands.newConnectWithoutSerialize(authentication.getAuthMethodName(), authData,
+                            this.protocolVersion, clientVersion, proxyToTargetBrokerAddress, null, null, null, null);
+                    cmd.getConnect().getFeatureFlags().setSupportsReplDedupByLidAndEid(false);
+                    return Commands.serializeWithSize(cmd);
+                }
+
+                @Override
+                public boolean isBrokerSupportsReplDedupByLidAndEid() {
+                    return supportsReplDedupByLidAndEid;
+                }
+
+                @Override
+                public ChannelHandlerContext ctx() {
+                    if (!injectRepeatedPublish) {
+                        return super.ctx();
+                    }
+                    final ChannelHandlerContext originalCtx = super.ctx;
+                    ChannelHandlerContext spyContext = spy(originalCtx);
+                    Answer injectedAnswer = invocation -> {
+                        // Do not repeat the messages re-sending, and clear the previous cached messages when
+                        // calling re-sending, to avoid publishing outs of order.
+                        for (StackTraceElement stackTraceElement : Thread.currentThread().getStackTrace()) {
+                            if (stackTraceElement.toString().contains("recoverProcessOpSendMsgFrom")
+                                    || stackTraceElement.toString().contains("resendMessages")) {
+                                duplicatedMsgs.clear();
+                                return invocation.callRealMethod();
+                            }
+                        }
+
+                        Object data = invocation.getArguments()[0];
+                        if (true && !(data instanceof ByteBufPair)) {
+                            return invocation.callRealMethod();
+                        }
+                        // Repeatedly send every message.
+                        ByteBufPair byteBufPair = (ByteBufPair) data;
+                        ByteBuf buf1 = byteBufPair.getFirst();
+                        ByteBuf buf2 = byteBufPair.getSecond();
+                        int bufferIndex1 = buf1.readerIndex();
+                        int bufferIndex2 = buf2.readerIndex();
+                        // Skip totalSize.
+                        buf1.readInt();
+                        int cmdSize = buf1.readInt();
+                        BaseCommand cmd = new BaseCommand();
+                        cmd.parseFrom(buf1, cmdSize);
+                        buf1.readerIndex(bufferIndex1);
+                        if (cmd.getType().equals(BaseCommand.Type.SEND)) {
+                            synchronized (duplicatedMsgs) {
+                                if (duplicatedMsgs.size() >= repeatedMessagesWindow) {
+                                    for (ByteBufPair bufferPair : duplicatedMsgs) {
+                                        originalCtx.channel().write(bufferPair, originalCtx.voidPromise());
+                                        originalCtx.channel().flush();
+                                    }
+                                    duplicatedMsgs.clear();
+                                }
+                            }
+                            ByteBuf newBuffer1 = UnpooledByteBufAllocator.DEFAULT.heapBuffer(
+                                    buf1.readableBytes());
+                            buf1.readBytes(newBuffer1);
+                            buf1.readerIndex(bufferIndex1);
+                            ByteBuf newBuffer2 = UnpooledByteBufAllocator.DEFAULT.heapBuffer(
+                                    buf2.readableBytes());
+                            buf2.readBytes(newBuffer2);
+                            buf2.readerIndex(bufferIndex2);
+                            synchronized (duplicatedMsgs) {
+                                if (newBuffer2.readableBytes() > 0) {
+                                    duplicatedMsgs.add(ByteBufPair.get(newBuffer1, newBuffer2));
+                                }
+                            }
+                            return invocation.callRealMethod();
+                        } else {
+                            return invocation.callRealMethod();
+                        }
+                    };
+                    doAnswer(injectedAnswer).when(spyContext).write(any());
+                    doAnswer(injectedAnswer).when(spyContext).write(any(), any(ChannelPromise.class));
+                    doAnswer(injectedAnswer).when(spyContext).writeAndFlush(any());
+                    doAnswer(injectedAnswer).when(spyContext).writeAndFlush(any(), any(ChannelPromise.class));
+                    return spyContext;
+                }
+            });
+
+        // 1. Create topics and enable deduplication.
+        final String topicName = BrokerTestUtil.newUniqueName("persistent://" + nonReplicatedNamespace + "/tp_");
+        admin1.topics().createNonPartitionedTopic(topicName);
+        admin1.topics().createSubscription(topicName, "s1", MessageId.earliest);
+        admin2.topics().createNonPartitionedTopic(topicName);
+        admin2.topics().createSubscription(topicName, "s1", MessageId.earliest);
+        Awaitility.await().atMost(Duration.ofSeconds(30)).untilAsserted(() -> {
+            PersistentTopic persistentTopic1 =
+                    (PersistentTopic) pulsar1.getBrokerService().getTopic(topicName, false).join().get();
+            PersistentTopic persistentTopic2 =
+                    (PersistentTopic) pulsar2.getBrokerService().getTopic(topicName, false).join().get();
+            admin1.topicPolicies().setDeduplicationStatus(topicName, true);
+            admin1.topicPolicies().setSchemaCompatibilityStrategy(topicName,
+                    SchemaCompatibilityStrategy.ALWAYS_COMPATIBLE);
+            admin2.topicPolicies().setDeduplicationStatus(topicName, true);
+            admin2.topicPolicies().setSchemaCompatibilityStrategy(topicName,
+                    SchemaCompatibilityStrategy.ALWAYS_COMPATIBLE);
+            MessageDeduplication messageDeduplication1 = persistentTopic1.getMessageDeduplication();
+            if (messageDeduplication1 != null) {
+                int snapshotInterval1 = WhiteboxImpl.getInternalState(messageDeduplication1, "snapshotInterval");
+                assertEquals(snapshotInterval1, 10);
+            }
+            MessageDeduplication messageDeduplication2 = persistentTopic2.getMessageDeduplication();
+            if (messageDeduplication2 != null) {
+                int snapshotInterval2 = WhiteboxImpl.getInternalState(messageDeduplication2, "snapshotInterval");
+                assertEquals(snapshotInterval2, 10);
+            }
+            assertEquals(persistentTopic1.getHierarchyTopicPolicies().getDeduplicationEnabled().get(), Boolean.TRUE);
+            assertEquals(persistentTopic1.getHierarchyTopicPolicies().getSchemaCompatibilityStrategy().get(),
+                    SchemaCompatibilityStrategy.ALWAYS_COMPATIBLE);
+            assertEquals(persistentTopic2.getHierarchyTopicPolicies().getDeduplicationEnabled().get(), Boolean.TRUE);
+            assertEquals(persistentTopic2.getHierarchyTopicPolicies().getSchemaCompatibilityStrategy().get(),
+                    SchemaCompatibilityStrategy.ALWAYS_COMPATIBLE);
+        });
+        PersistentTopic tp1 =
+                (PersistentTopic) pulsar1.getBrokerService().getTopic(topicName, false).join().get();
+        PersistentTopic tp2 =
+                (PersistentTopic) pulsar2.getBrokerService().getTopic(topicName, false).join().get();
+
+        // 2, Publish messages.
+        List<String> msgSent = new ArrayList<>();
+        Producer<Integer> p1 = client1.newProducer(Schema.INT32).topic(topicName).create();
+        Producer<Integer> p2 = client1.newProducer(Schema.INT32).topic(topicName).create();
+        Producer<String> p3 = client1.newProducer(Schema.STRING).topic(topicName).create();
+        Producer<Boolean> p4 = client1.newProducer(Schema.BOOL).topic(topicName).create();
+        for (int i = 0; i < 10; i++) {
+            p1.send(i);
+            msgSent.add(String.valueOf(i));
+        }
+        for (int i = 10; i < 200; i++) {
+            int msg1 = i;
+            int msg2 = 1000 + i;
+            String msg3 = (2000 + i) + "";
+            boolean msg4 = i % 2 == 0;
+            p1.send(msg1);
+            p2.send(msg2);
+            msgSent.add(String.valueOf(msg1));
+            msgSent.add(String.valueOf(msg2));
+            if (multiSchemas) {
+                p3.send(msg3);
+                p4.send(msg4);
+                msgSent.add(String.valueOf(msg3));
+                msgSent.add(String.valueOf(msg4));
+            }
+        }
+        p1.close();
+        p2.close();
+        p3.close();
+        p4.close();
+
+        // 3. Enable replication and wait the task to be finished.
+        admin1.topics().setReplicationClusters(topicName, Arrays.asList(cluster1, cluster2));
+        waitReplicatorStarted(topicName);
+        Awaitility.await().atMost(Duration.ofSeconds(60)).untilAsserted(() -> {
+            for (ManagedCursor cursor : tp1.getManagedLedger().getCursors()) {
+                if (cursor.getName().equals("pulsar.repl.r2")) {
+                    long replBacklog = cursor.getNumberOfEntriesInBacklog(true);
+                    log.info("repl backlog: {}", replBacklog);
+                    assertEquals(replBacklog, 0);
+                }
+            }
+        });
+
+        // Verify: all messages were copied correctly.
+        List<String> msgReceived = new ArrayList<>();
+        Consumer<GenericRecord> consumer = client2.newConsumer(Schema.AUTO_CONSUME()).topic(topicName)
+                .subscriptionName("s1").subscribe();
+        while (true) {
+            Message<GenericRecord> msg = consumer.receive(10, TimeUnit.SECONDS);
+            if (msg == null) {
+                break;
+            }
+            MessageIdAdv messageIdAdv = (MessageIdAdv) msg.getMessageId();
+            log.info("received msg. source {}, target {}:{}", StringUtils.join(msg.getProperties().values(), ":"),
+                    messageIdAdv.getLedgerId(), messageIdAdv.getEntryId());
+            msgReceived.add(String.valueOf(msg.getValue()));
+            consumer.acknowledgeAsync(msg);
+        }
+        log.info("c1 topic stats-internal: "
+                + JACKSON.writeValueAsString(admin1.topics().getInternalStats(topicName)));
+        log.info("c2 topic stats-internal: "
+                + JACKSON.writeValueAsString(admin2.topics().getInternalStats(topicName)));
+        log.info("c1 topic stats-internal: "
+                + JACKSON.writeValueAsString(admin1.topics().getStats(topicName)));
+        log.info("c2 topic stats-internal: "
+                + JACKSON.writeValueAsString(admin2.topics().getStats(topicName)));
+        assertEquals(msgReceived, msgSent);
+        consumer.close();
+
+        // Verify: the deduplication cursor has been acked.
+        // "topic-policy.DeduplicationSnapshotInterval" is "10".
+        Awaitility.await().untilAsserted(() -> {
+            for (ManagedCursor cursor : tp1.getManagedLedger().getCursors()) {
+                if (cursor.getName().equals("pulsar.dedup")) {
+                    assertTrue(cursor.getNumberOfEntriesInBacklog(true) < 10);
+                }
+            }
+            for (ManagedCursor cursor : tp2.getManagedLedger().getCursors()) {
+                if (cursor.getName().equals("pulsar.dedup")) {
+                    assertTrue(cursor.getNumberOfEntriesInBacklog(true) < 10);
+                }
+            }
+        });
+        // Remove the injection.
+        taskToClearInjection.run();
+
+        log.info("======  Verify: all messages will be replicated after reopening replication  ======");
+
+        // Verify: all messages will be replicated after reopening replication.
+        // Reopen replication: stop replication.
+        admin1.topics().setReplicationClusters(topicName, Arrays.asList(cluster1));
+        waitReplicatorStopped(topicName);
+        admin2.topics().unload(topicName);
+        admin2.topics().delete(topicName);
+        // Reopen replication: enable replication.
+        admin2.topics().createNonPartitionedTopic(topicName);
+        admin2.topics().createSubscription(topicName, "s1", MessageId.earliest);
+        Awaitility.await().atMost(Duration.ofSeconds(30)).untilAsserted(() -> {
+            PersistentTopic persistentTopic2 =
+                    (PersistentTopic) pulsar2.getBrokerService().getTopic(topicName, false).join().get();
+            admin2.topicPolicies().setDeduplicationStatus(topicName, true);
+            admin2.topicPolicies().setSchemaCompatibilityStrategy(topicName,
+                    SchemaCompatibilityStrategy.ALWAYS_COMPATIBLE);
+            MessageDeduplication messageDeduplication2 = persistentTopic2.getMessageDeduplication();
+            if (messageDeduplication2 != null) {
+                int snapshotInterval2 = WhiteboxImpl.getInternalState(messageDeduplication2, "snapshotInterval");
+                assertEquals(snapshotInterval2, 10);
+            }
+            assertEquals(persistentTopic2.getHierarchyTopicPolicies().getDeduplicationEnabled().get(), Boolean.TRUE);
+            assertEquals(persistentTopic2.getHierarchyTopicPolicies().getSchemaCompatibilityStrategy().get(),
+                    SchemaCompatibilityStrategy.ALWAYS_COMPATIBLE);
+        });
+        admin1.topics().setReplicationClusters(topicName, Arrays.asList(cluster1, cluster2));
+        Awaitility.await().atMost(Duration.ofSeconds(60)).untilAsserted(() -> {
+            for (ManagedCursor cursor : tp2.getManagedLedger().getCursors()) {
+                if (cursor.getName().equals("pulsar.repl.c2")) {
+                    assertEquals(cursor.getNumberOfEntriesInBacklog(true), 0);
+                }
+            }
+        });
+        // Reopen replication: consumption.
+        List<String> msgReceived2 = new ArrayList<>();
+        Consumer<GenericRecord> consumer2 = client2.newConsumer(Schema.AUTO_CONSUME()).topic(topicName)
+                .subscriptionName("s1").subscribe();
+        while (true) {
+            Message<GenericRecord> msg = consumer2.receive(10, TimeUnit.SECONDS);
+            if (msg == null) {
+                break;
+            }
+            MessageIdAdv messageIdAdv = (MessageIdAdv) msg.getMessageId();
+            log.info("received msg. source {}, target {}:{}", StringUtils.join(msg.getProperties().values(), ":"),
+                    messageIdAdv.getLedgerId(), messageIdAdv.getEntryId());
+            msgReceived2.add(String.valueOf(msg.getValue()));
+            consumer2.acknowledgeAsync(msg);
+        }
+        // Verify: all messages were copied correctly.
+        log.info("c1 topic stats-internal: "
+                + JACKSON.writeValueAsString(admin1.topics().getInternalStats(topicName)));
+        log.info("c2 topic stats-internal: "
+                + JACKSON.writeValueAsString(admin2.topics().getInternalStats(topicName)));
+        log.info("c1 topic stats-internal: "
+                + JACKSON.writeValueAsString(admin1.topics().getStats(topicName)));
+        log.info("c2 topic stats-internal: "
+                + JACKSON.writeValueAsString(admin2.topics().getStats(topicName)));
+        assertEquals(msgReceived2, msgSent);
+        consumer2.close();
+
+        // cleanup.
+        admin1.topics().setReplicationClusters(topicName, Arrays.asList(cluster1));
+        waitReplicatorStopped(topicName);
+        Awaitility.await().until(() -> {
+            for (ManagedCursor cursor : tp1.getManagedLedger().getCursors()) {
+                if (cursor.getName().equals("pulsar.repl.r2")) {
+                    return false;
+                }
+            }
+            return true;
+        });
+        admin1.topics().delete(topicName);
+        admin2.topics().delete(topicName);
+    }
+
+    @DataProvider(name = "enabledDeduplication")
+    public Object[][] enabledDeduplication() {
+        return new Object[][] {
+                {true},
+                {false}
+        };
+    }
+
+    /***
+     * To reproduce the issue that replication loss message if enabled deduplication
+     * 1. Publishing in the source cluster
+     *   1-1. Producer-1 send 2 messages: M1, M2
+     *   1-2. Producer-2 send 2 messages: M3, M4
+     * 2. Replicate messages to the remote cluster
+     *   2-1. Copies M1 and M2
+     *   2-2. Repeatedly copies M1 and M2. and copies M3 and M4.
+     *     2-2-1. After repeatedly copies M1 and M2, the network broke.
+     * 3. After a topic unloading.
+     *   3-1. The replicator will start after the topic is loaded up.
+     *   3-2. The client will create a new connection.
+     * 4. Verify: All 4 messages are copied to the remote cluster.
+     */
+    @Test(timeOut = 360 * 1000, dataProvider = "enabledDeduplication")
+    public void testDeduplicationNotLostMessage(boolean enabledDeduplication) throws Exception {
+        waitInternalClientCreated();
+
+        /**
+         * step-2: Inject a mechanism that makes the client connect broke after repeatedly copied M1 and M2.
+         */
+        final List<ByteBufPair> duplicatedMsgs = new ArrayList<>();
+        final int repeatMsgIndex = 2;
+        AtomicInteger msgSent = new AtomicInteger(0);
+        ConcurrentHashSet<Channel> injectedChannel = new ConcurrentHashSet<>();
+        Runnable taskToClearInjection = injectReplicatorClientCnx(
+                (conf, eventLoopGroup) -> new ClientCnx(conf, eventLoopGroup) {
+
+                    @Override
+                    public ChannelHandlerContext ctx() {
+                        final ChannelHandlerContext originalCtx = super.ctx;
+                        ChannelHandlerContext spyContext = spy(originalCtx);
+                        Answer injectedAnswer = invocation -> {
+                            // Do not repeat the messages re-sending, and clear the previous cached messages when
+                            // calling re-sending, to avoid publishing outs of order.
+                            for (StackTraceElement stackTraceElement : Thread.currentThread().getStackTrace()) {
+                                if (stackTraceElement.toString().contains("recoverProcessOpSendMsgFrom")
+                                        || stackTraceElement.toString().contains("resendMessages")) {
+                                    duplicatedMsgs.clear();
+                                    return invocation.callRealMethod();
+                                }
+                            }
+
+                            Object data = invocation.getArguments()[0];
+                            if (true && !(data instanceof ByteBufPair)) {
+                                return invocation.callRealMethod();
+                            }
+                            // Repeatedly send every message.
+                            ByteBufPair byteBufPair = (ByteBufPair) data;
+                            ByteBuf buf1 = byteBufPair.getFirst();
+                            ByteBuf buf2 = byteBufPair.getSecond();
+                            int bufferIndex1 = buf1.readerIndex();
+                            int bufferIndex2 = buf2.readerIndex();
+                            // Skip totalSize.
+                            buf1.readInt();
+                            int cmdSize = buf1.readInt();
+                            BaseCommand cmd = new BaseCommand();
+                            cmd.parseFrom(buf1, cmdSize);
+                            buf1.readerIndex(bufferIndex1);
+                            if (cmd.getType().equals(BaseCommand.Type.SEND)) {
+                                synchronized (duplicatedMsgs) {
+                                    if (duplicatedMsgs.isEmpty() && msgSent.get() == repeatMsgIndex) {
+                                        return null;
+                                    }
+                                    if (msgSent.get() == repeatMsgIndex) {
+                                        for (ByteBufPair bufferPair : duplicatedMsgs) {
+                                            originalCtx.channel().write(bufferPair, originalCtx.voidPromise());
+                                            originalCtx.channel().flush();
+                                        }
+                                        duplicatedMsgs.clear();
+                                        return null;
+                                    }
+                                }
+                                ByteBuf newBuffer1 = UnpooledByteBufAllocator.DEFAULT.heapBuffer(
+                                        buf1.readableBytes());
+                                buf1.readBytes(newBuffer1);
+                                buf1.readerIndex(bufferIndex1);
+                                ByteBuf newBuffer2 = UnpooledByteBufAllocator.DEFAULT.heapBuffer(
+                                        buf2.readableBytes());
+                                buf2.readBytes(newBuffer2);
+                                buf2.readerIndex(bufferIndex2);
+                                synchronized (duplicatedMsgs) {
+                                    if (newBuffer2.readableBytes() > 0 && msgSent.incrementAndGet() <= repeatMsgIndex) {
+                                        duplicatedMsgs.add(ByteBufPair.get(newBuffer1, newBuffer2));
+                                    }
+                                }
+                                return invocation.callRealMethod();
+                            } else {
+                                return invocation.callRealMethod();
+                            }
+                        };
+                        doAnswer(injectedAnswer).when(spyContext).write(any());
+                        doAnswer(injectedAnswer).when(spyContext).write(any(), any(ChannelPromise.class));
+                        doAnswer(injectedAnswer).when(spyContext).writeAndFlush(any());
+                        doAnswer(injectedAnswer).when(spyContext).writeAndFlush(any(), any(ChannelPromise.class));
+                        injectedChannel.add(originalCtx.channel());
+                        return spyContext;
+                    }
+                });
+
+        // Create topics and enable deduplication.
+        final String topicName = BrokerTestUtil.newUniqueName("persistent://" + nonReplicatedNamespace + "/tp_");
+        admin1.topics().createNonPartitionedTopic(topicName);
+        admin1.topics().createSubscription(topicName, "s1", MessageId.earliest);
+        admin2.topics().createNonPartitionedTopic(topicName);
+        admin2.topics().createSubscription(topicName, "s1", MessageId.earliest);
+        PersistentTopic tp1 =
+                (PersistentTopic) pulsar1.getBrokerService().getTopic(topicName, false).join().get();
+        PersistentTopic tp2 =
+                (PersistentTopic) pulsar2.getBrokerService().getTopic(topicName, false).join().get();
+        ManagedLedgerImpl ml2 = (ManagedLedgerImpl) tp2.getManagedLedger();
+        if (enabledDeduplication) {
+            Awaitility.await().atMost(Duration.ofSeconds(30)).untilAsserted(() -> {
+                PersistentTopic persistentTopic1 =
+                        (PersistentTopic) pulsar1.getBrokerService().getTopic(topicName, false).join().get();
+                PersistentTopic persistentTopic2 =
+                        (PersistentTopic) pulsar2.getBrokerService().getTopic(topicName, false).join().get();
+                admin1.topicPolicies().setDeduplicationStatus(topicName, true);
+                admin2.topicPolicies().setDeduplicationStatus(topicName, true);
+                assertEquals(persistentTopic1.getHierarchyTopicPolicies().getDeduplicationEnabled().get(),
+                        Boolean.TRUE);
+                assertEquals(persistentTopic2.getHierarchyTopicPolicies().getDeduplicationEnabled().get(),
+                        Boolean.TRUE);
+            });
+        }
+        // Let broker persist messages one by one, in other words, it starts to persist the next message after the
+        // previous has been written into BKs.
+        PersistentTopic spyTp2 = spy(tp2);
+        doAnswer(invocation -> {
+            try {
+                Awaitility.await().atMost(Duration.ofSeconds(3)).untilAsserted(() -> {
+                    assertEquals(ml2.getPendingAddEntriesCount(), 0);
+                });
+            } catch (Throwable throwable) {
+                // Ignore this timeout error.
+            }
+            return invocation.callRealMethod();
+        }).when(spyTp2).publishMessage(any(ByteBuf.class), any(Topic.PublishContext.class));
+        CompletableFuture<Optional<Topic>> originalTp2 = pulsar2.getBrokerService().getTopics().put(tp2.getName(),
+                CompletableFuture.completedFuture(Optional.of(spyTp2)));
+
+        /**
+         * Step-1: Publishes messages in the source cluster and start replication,
+         */
+        ProducerImpl p1 = (ProducerImpl) client1.newProducer().topic(topicName).producerName("p1").create();
+        ProducerImpl p2 = (ProducerImpl) client1.newProducer().topic(topicName).producerName("p2").create();
+        p1.send("1".toString().getBytes(StandardCharsets.UTF_8));
+        p1.send("2".toString().getBytes(StandardCharsets.UTF_8));
+        p2.send("3".toString().getBytes(StandardCharsets.UTF_8));
+        p2.send("4".toString().getBytes(StandardCharsets.UTF_8));
+
+        // Enable replication and wait the task to be finished, it should not finish if no bug.
+        admin1.topics().setReplicationClusters(topicName, Arrays.asList(cluster1, cluster2));
+        waitReplicatorStarted(topicName);
+        try {
+            Awaitility.await().atMost(Duration.ofSeconds(20)).pollInterval(Duration.ofSeconds(1)).untilAsserted(() -> {
+                for (ManagedCursor cursor : tp1.getManagedLedger().getCursors()) {
+                    if (cursor.getName().equals("pulsar.repl.r2")) {
+                        long replBacklog = cursor.getNumberOfEntriesInBacklog(true);
+                        log.info("repl backlog: {}", replBacklog);
+                        assertEquals(replBacklog, 0);
+                    }
+                }
+            });
+        } catch (Throwable t) {
+            // Ignore the error.
+        }
+
+        /**
+         * Step-3: remove the injections, unload topics and rebuild connections of the replicator.
+         */
+        taskToClearInjection.run();
+        pulsar2.getBrokerService().getTopics().put(tp2.getName(), originalTp2);
+        admin1.topics().unload(topicName);
+        admin2.topics().unload(topicName);
+        for (Channel channel : injectedChannel) {
+            channel.close();
+        }
+        waitReplicatorStarted(topicName);
+        PersistentTopic tp12 =
+                (PersistentTopic) pulsar1.getBrokerService().getTopic(topicName, false).join().get();
+        PersistentTopic tp22 =
+                (PersistentTopic) pulsar2.getBrokerService().getTopic(topicName, false).join().get();
+        Awaitility.await().atMost(Duration.ofSeconds(20)).pollInterval(Duration.ofSeconds(1)).untilAsserted(() -> {
+            for (ManagedCursor cursor : tp12.getManagedLedger().getCursors()) {
+                if (cursor.getName().equals("pulsar.repl.r2")) {
+                    long replBacklog = cursor.getNumberOfEntriesInBacklog(true);
+                    log.info("repl backlog: {}", replBacklog);
+                    assertEquals(replBacklog, 0);
+                }
+            }
+        });
+
+        /**
+         * Verify: All 4 messages are copied to the remote cluster.
+         */
+        List<String> msgReceived = new ArrayList<>();
+        Consumer consumer = client2.newConsumer().topic(topicName)
+                .subscriptionName("s1").subscribe();
+        while (true) {
+            Message msg = consumer.receive(10, TimeUnit.SECONDS);
+            if (msg == null) {
+                break;
+            }
+            MessageIdAdv messageIdAdv = (MessageIdAdv) msg.getMessageId();
+            log.info("received msg. source {}, target {}:{}", StringUtils.join(msg.getProperties().values(), ":"),
+                    messageIdAdv.getLedgerId(), messageIdAdv.getEntryId());
+            msgReceived.add(new String(msg.getData(), StandardCharsets.UTF_8));
+            consumer.acknowledgeAsync(msg);
+        }
+
+        log.info("received msgs: {}", msgReceived);
+        assertTrue(msgReceived.contains("1"));
+        assertTrue(msgReceived.contains("2"));
+        assertTrue(msgReceived.contains("3"));
+        assertTrue(msgReceived.contains("4"));
+        if (enabledDeduplication) {
+            assertEquals(msgReceived, Arrays.asList("1", "2", "3", "4"));
+        }
+
+        // cleanup.
+        consumer.close();
+        p1.close();
+        p2.close();
+        admin1.topics().setReplicationClusters(topicName, Arrays.asList(cluster1));
+        waitReplicatorStopped(topicName);
+        Awaitility.await().until(() -> {
+            for (ManagedCursor cursor : tp12.getManagedLedger().getCursors()) {
+                if (cursor.getName().equals("pulsar.repl.r2")) {
+                    return false;
+                }
+            }
+            return true;
+        });
+        admin1.topics().delete(topicName);
+        admin2.topics().delete(topicName);
+    }
+
+    @Test(timeOut = 360 * 1000, dataProvider = "enabledDeduplication")
+    public void testReplicationLoadSchemaTimeout(boolean enabledDeduplication) throws Exception {
+        waitInternalClientCreated();
+
+        /**
+         * Inject a timeout error for Get Schema.
+         */
+        Field filedSchemaRegistryService = PulsarService.class.getDeclaredField("schemaRegistryService");
+        filedSchemaRegistryService.setAccessible(true);
+        SchemaRegistryService originalSchemaRegistryService =
+                (SchemaRegistryService) filedSchemaRegistryService.get(pulsar2);
+        SchemaRegistryService spySchemaRegistryService = spy(originalSchemaRegistryService);
+        AtomicBoolean getSchemaSuccess = new AtomicBoolean(false);
+        doAnswer(invocation -> {
+            if (getSchemaSuccess.get()) {
+                getSchemaSuccess.set(false);
+                return invocation.callRealMethod();
+            } else {
+                getSchemaSuccess.set(true);
+            }
+            Thread.sleep(60 * 1000);
+            return invocation.callRealMethod();
+        }).when(spySchemaRegistryService).findSchemaVersion(any(String.class), any(SchemaData.class));
+        filedSchemaRegistryService.set(pulsar2, spySchemaRegistryService);
+        Runnable taskToClearInjection = injectReplicatorClientCnx(
+            (conf, eventLoopGroup) -> new ClientCnx(conf, eventLoopGroup) {
+                @Override
+                protected void handleGetSchemaResponse(CommandGetSchemaResponse commandGetSchemaResponse) {
+                    if (getSchemaSuccess.get()) {
+                        getSchemaSuccess.set(false);
+                        super.handleGetSchemaResponse(commandGetSchemaResponse);
+                        return;
+                    } else {
+                        getSchemaSuccess.set(true);
+                    }
+                    checkArgument(state == State.Ready);
+                    long requestId = commandGetSchemaResponse.getRequestId();
+                    CompletableFuture<CommandGetSchemaResponse> future =
+                            (CompletableFuture<CommandGetSchemaResponse>) pendingRequests.remove(requestId);
+                    if (future == null) {
+                        duplicatedResponseCounter.incrementAndGet();
+                        log.warn("{} Received unknown request id from server: {}", ctx.channel(), requestId);
+                        return;
+                    }
+                    future.completeExceptionally(new PulsarClientException.TimeoutException("Mocked timeout"));
+                }
+
+                @Override
+                protected void handleGetOrCreateSchemaResponse(CommandGetOrCreateSchemaResponse
+                                                                       commandGetOrCreateSchemaResponse) {
+
+                    if (getSchemaSuccess.get()) {
+                        getSchemaSuccess.set(false);
+                        super.handleGetOrCreateSchemaResponse(commandGetOrCreateSchemaResponse);
+                        return;
+                    } else {
+                        getSchemaSuccess.set(true);
+                    }
+
+                    checkArgument(state == State.Ready);
+                    long requestId = commandGetOrCreateSchemaResponse.getRequestId();
+                    CompletableFuture<CommandGetOrCreateSchemaResponse> future =
+                            (CompletableFuture<CommandGetOrCreateSchemaResponse>) pendingRequests.remove(requestId);
+                    if (future == null) {
+                        duplicatedResponseCounter.incrementAndGet();
+                        log.warn("{} Received unknown request id from server: {}", ctx.channel(), requestId);
+                        return;
+                    }
+                    future.completeExceptionally(new PulsarClientException.TimeoutException("Mocked timeout"));
+                }
+            });
+
+        // Create topics and enable deduplication.
+        final String topicName = BrokerTestUtil.newUniqueName("persistent://" + nonReplicatedNamespace + "/tp_");
+        admin1.topics().createNonPartitionedTopic(topicName);
+        admin1.topics().createSubscription(topicName, "s1", MessageId.earliest);
+        admin2.topics().createNonPartitionedTopic(topicName);
+        admin2.topics().createSubscription(topicName, "s1", MessageId.earliest);
+        PersistentTopic tp1 =
+                (PersistentTopic) pulsar1.getBrokerService().getTopic(topicName, false).join().get();
+        PersistentTopic tp2 =
+                (PersistentTopic) pulsar2.getBrokerService().getTopic(topicName, false).join().get();
+        if (enabledDeduplication) {
+            Awaitility.await().atMost(Duration.ofSeconds(30)).untilAsserted(() -> {
+                PersistentTopic persistentTopic1 =
+                        (PersistentTopic) pulsar1.getBrokerService().getTopic(topicName, false).join().get();
+                PersistentTopic persistentTopic2 =
+                        (PersistentTopic) pulsar2.getBrokerService().getTopic(topicName, false).join().get();
+                admin1.topicPolicies().setDeduplicationStatus(topicName, true);
+                admin2.topicPolicies().setDeduplicationStatus(topicName, true);
+                assertEquals(persistentTopic1.getHierarchyTopicPolicies().getDeduplicationEnabled().get(),
+                        Boolean.TRUE);
+                assertEquals(persistentTopic2.getHierarchyTopicPolicies().getDeduplicationEnabled().get(),
+                        Boolean.TRUE);
+            });
+        }
+        Awaitility.await().atMost(Duration.ofSeconds(30)).untilAsserted(() -> {
+            PersistentTopic persistentTopic1 =
+                    (PersistentTopic) pulsar1.getBrokerService().getTopic(topicName, false).join().get();
+            PersistentTopic persistentTopic2 =
+                    (PersistentTopic) pulsar2.getBrokerService().getTopic(topicName, false).join().get();
+            admin1.topicPolicies().setSchemaCompatibilityStrategy(topicName,
+                    SchemaCompatibilityStrategy.ALWAYS_COMPATIBLE);
+            admin2.topicPolicies().setSchemaCompatibilityStrategy(topicName,
+                    SchemaCompatibilityStrategy.ALWAYS_COMPATIBLE);
+            assertEquals(persistentTopic1.getHierarchyTopicPolicies().getSchemaCompatibilityStrategy().get(),
+                    SchemaCompatibilityStrategy.ALWAYS_COMPATIBLE);
+            assertEquals(persistentTopic2.getHierarchyTopicPolicies().getSchemaCompatibilityStrategy().get(),
+                    SchemaCompatibilityStrategy.ALWAYS_COMPATIBLE);
+        });
+
+        // Publishes messages in the source cluster.
+        Producer p1 = client1.newProducer().topic(topicName).producerName("p1").create();
+        Producer p2 = client1.newProducer().topic(topicName).producerName("p2").create();
+        Producer p3 = client1.newProducer(Schema.STRING).topic(topicName).producerName("p3").create();
+        p1.send("1".toString().getBytes(StandardCharsets.UTF_8));
+        p1.send("2".toString().getBytes(StandardCharsets.UTF_8));
+        p3.send("2-1");
+        p3.send("2-2");
+        p2.send("3".toString().getBytes(StandardCharsets.UTF_8));
+        p2.send("4".toString().getBytes(StandardCharsets.UTF_8));
+
+        // Enable replication and wait the task to be finished, it should not finish if no bug.
+        admin1.topics().setReplicationClusters(topicName, Arrays.asList(cluster1, cluster2));
+        waitReplicatorStarted(topicName);
+        Awaitility.await().atMost(Duration.ofSeconds(180)).pollInterval(Duration.ofSeconds(1)).untilAsserted(() -> {
+            for (ManagedCursor cursor : tp1.getManagedLedger().getCursors()) {
+                if (cursor.getName().equals("pulsar.repl.r2")) {
+                    long replBacklog = cursor.getNumberOfEntriesInBacklog(true);
+                    log.info("repl backlog: {}", replBacklog);
+                    assertEquals(replBacklog, 0);
+                }
+            }
+        });
+
+        // Verify: All messages are copied to the remote cluster.
+        List<String> msgReceived = new ArrayList<>();
+        Consumer consumer = client2.newConsumer().topic(topicName)
+                .subscriptionName("s1").subscribe();
+        while (true) {
+            Message msg = consumer.receive(10, TimeUnit.SECONDS);
+            if (msg == null) {
+                break;
+            }
+            MessageIdAdv messageIdAdv = (MessageIdAdv) msg.getMessageId();
+            log.info("received msg. source {}, target {}:{}", StringUtils.join(msg.getProperties().values(), ":"),
+                    messageIdAdv.getLedgerId(), messageIdAdv.getEntryId());
+            msgReceived.add(new String(msg.getData(), StandardCharsets.UTF_8));
+            consumer.acknowledgeAsync(msg);
+        }
+        log.info("received msgs: {}", msgReceived);
+        assertTrue(msgReceived.contains("1"));
+        assertTrue(msgReceived.contains("2"));
+        assertTrue(msgReceived.contains("2-1"));
+        assertTrue(msgReceived.contains("2-2"));
+        assertTrue(msgReceived.contains("3"));
+        assertTrue(msgReceived.contains("4"));
+        if (enabledDeduplication) {
+            assertEquals(msgReceived, Arrays.asList("1", "2", "2-1", "2-2", "3", "4"));
+        }
+
+        // cleanup.
+        taskToClearInjection.run();
+        filedSchemaRegistryService.set(pulsar2, originalSchemaRegistryService);
+        consumer.close();
+        p1.close();
+        p2.close();
+        p3.close();
+        admin1.topics().setReplicationClusters(topicName, Arrays.asList(cluster1));
+        waitReplicatorStopped(topicName);
+        Awaitility.await().until(() -> {
+            for (ManagedCursor cursor : tp1.getManagedLedger().getCursors()) {
+                if (cursor.getName().equals("pulsar.repl.r2")) {
+                    return false;
+                }
+            }
+            return true;
+        });
+        admin1.topics().delete(topicName);
+        admin2.topics().delete(topicName);
+    }
+}
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java
index 75ff51055fc..ec37ffd3e1f 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java
@@ -403,9 +403,9 @@ public class ReplicatorTest extends ReplicatorTestBase {
 
         int lastId = -1;
         for (int i = 0; i < totalMessages; i++) {
-            Message<GenericRecord> msg1 = consumer1.receive();
-            Message<GenericRecord> msg2 = consumer2.receive();
-            Message<GenericRecord> msg3 = consumer3.receive();
+            Message<GenericRecord> msg1 = consumer1.receive(10, TimeUnit.SECONDS);
+            Message<GenericRecord> msg2 = consumer2.receive(10, TimeUnit.SECONDS);
+            Message<GenericRecord> msg3 = consumer3.receive(10, TimeUnit.SECONDS);
             assertTrue(msg1 != null && msg2 != null && msg3 != null);
             GenericRecord record1 = msg1.getValue();
             GenericRecord record2 = msg2.getValue();
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java
index 675fa206347..89bc2e237a2 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java
@@ -117,10 +117,12 @@ public class ClientCnx extends PulsarHandler {
     protected final Authentication authentication;
     protected State state;
 
-    private AtomicLong duplicatedResponseCounter = new AtomicLong(0);
+    @VisibleForTesting
+    protected AtomicLong duplicatedResponseCounter = new AtomicLong(0);
 
+    @VisibleForTesting
     @Getter
-    private final ConcurrentLongHashMap<TimedCompletableFuture<? extends Object>> pendingRequests =
+    protected final ConcurrentLongHashMap<TimedCompletableFuture<? extends Object>> pendingRequests =
             ConcurrentLongHashMap.<TimedCompletableFuture<? extends Object>>newBuilder()
                     .expectedItems(16)
                     .concurrencyLevel(1)
@@ -188,6 +190,8 @@ public class ClientCnx extends PulsarHandler {
     private boolean supportsTopicWatchers;
     @Getter
     private boolean supportsGetPartitionedMetadataWithoutAutoCreation;
+    @Getter
+    private boolean brokerSupportsReplDedupByLidAndEid;
 
     /** Idle stat. **/
     @Getter
@@ -196,7 +200,7 @@ public class ClientCnx extends PulsarHandler {
     @Getter
     private long lastDisconnectedTimestamp;
 
-    private final String clientVersion;
+    protected final String clientVersion;
 
     protected enum State {
         None, SentConnectFrame, Ready, Failed, Connecting
@@ -387,6 +391,8 @@ public class ClientCnx extends PulsarHandler {
         supportsGetPartitionedMetadataWithoutAutoCreation =
             connected.hasFeatureFlags()
                     && connected.getFeatureFlags().isSupportsGetPartitionedMetadataWithoutAutoCreation();
+        brokerSupportsReplDedupByLidAndEid =
+            connected.hasFeatureFlags() && connected.getFeatureFlags().isSupportsReplDedupByLidAndEid();
 
         // set remote protocol version to the correct version before we complete the connection future
         setRemoteEndpointProtocolVersion(connected.getProtocolVersion());
@@ -456,18 +462,19 @@ public class ClientCnx extends PulsarHandler {
             ledgerId = sendReceipt.getMessageId().getLedgerId();
             entryId = sendReceipt.getMessageId().getEntryId();
         }
-
+        ProducerImpl<?> producer = producers.get(producerId);
         if (ledgerId == -1 && entryId == -1) {
-            log.warn("{} Message with sequence-id {} published by producer {} has been dropped", ctx.channel(),
-                    sequenceId, producerId);
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug("{} Got receipt for producer: {} -- msg: {} -- id: {}:{}", ctx.channel(), producerId, sequenceId,
-                    ledgerId, entryId);
+            log.warn("{} Message with sequence-id {}-{} published by producer [id:{}, name:{}] has been dropped",
+                    ctx.channel(), sequenceId, highestSequenceId, producerId,
+                    producer != null ? producer.getProducerName() : "null");
+        } else {
+            if (log.isDebugEnabled()) {
+                log.debug("{} Got receipt for producer: [id:{}, name:{}] -- sequence-id: {}-{} -- entry-id: {}:{}",
+                        ctx.channel(), producerId, producer.getProducerName(), sequenceId, highestSequenceId,
+                        ledgerId, entryId);
+            }
         }
 
-        ProducerImpl<?> producer = producers.get(producerId);
         if (producer != null) {
             producer.ackReceived(this, sequenceId, highestSequenceId, ledgerId, entryId);
         } else {
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/GeoReplicationProducerImpl.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/GeoReplicationProducerImpl.java
new file mode 100644
index 00000000000..3201dde748f
--- /dev/null
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/GeoReplicationProducerImpl.java
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.impl;
+
+import io.netty.util.ReferenceCountUtil;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pulsar.client.api.Schema;
+import org.apache.pulsar.client.impl.conf.ProducerConfigurationData;
+import org.apache.pulsar.common.api.proto.KeyValue;
+import org.apache.pulsar.common.naming.TopicName;
+import org.apache.pulsar.common.protocol.Markers;
+
+@Slf4j
+public class GeoReplicationProducerImpl extends ProducerImpl{
+
+    public static final String MSG_PROP_REPL_SOURCE_POSITION = "__MSG_PROP_REPL_SOURCE_POSITION";
+    public static final String MSG_PROP_IS_REPL_MARKER = "__MSG_PROP_IS_REPL_MARKER";
+
+    private long lastPersistedSourceLedgerId;
+    private long lastPersistedSourceEntryId;
+
+    private final boolean isPersistentTopic;
+
+    public GeoReplicationProducerImpl(PulsarClientImpl client, String topic,
+                                      ProducerConfigurationData conf,
+                                      CompletableFuture producerCreatedFuture, int partitionIndex,
+                                      Schema schema, ProducerInterceptors interceptors,
+                                      Optional overrideProducerName) {
+        super(client, topic, conf, producerCreatedFuture, partitionIndex, schema, interceptors, overrideProducerName);
+        isPersistentTopic = TopicName.get(topic).isPersistent();
+    }
+
+    private boolean isBrokerSupportsReplDedupByLidAndEid(ClientCnx cnx) {
+        // Non-Persistent topic does not have ledger id or entry id, so it does not support.
+        return cnx.isBrokerSupportsReplDedupByLidAndEid() && isPersistentTopic;
+    }
+
+    @Override
+    protected void ackReceived(ClientCnx cnx, long seq, long highSeq, long ledgerId, long entryId) {
+        if (!isBrokerSupportsReplDedupByLidAndEid(cnx)) {
+            // Repl V1 is the same as normal for this handling.
+            super.ackReceived(cnx, seq, highSeq, ledgerId, entryId);
+            return;
+        }
+        synchronized (this) {
+            OpSendMsg op = pendingMessages.peek();
+            if (op == null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("[{}] [{}] Got ack for timed out msg {}:{}", topic, producerName, seq, highSeq);
+                }
+                return;
+            }
+            // Replicator send markers also, use sequenceId to check the marker send-receipt.
+            if (isReplicationMarker(highSeq)) {
+                ackReceivedReplMarker(cnx, op, seq, highSeq, ledgerId, entryId);
+                return;
+            }
+            ackReceivedReplicatedMsg(cnx, op, seq, highSeq, ledgerId, entryId);
+        }
+    }
+
+    private void ackReceivedReplicatedMsg(ClientCnx cnx, OpSendMsg op, long sourceLId, long sourceEId,
+                                          long targetLId, long targetEid) {
+        // Parse source cluster's entry position.
+        Long pendingLId = null;
+        Long pendingEId = null;
+        List<KeyValue> kvPairList =  op.msg.getMessageBuilder().getPropertiesList();
+        for (KeyValue kvPair : kvPairList) {
+            if (kvPair.getKey().equals(MSG_PROP_REPL_SOURCE_POSITION)) {
+                if (!kvPair.getValue().contains(":")) {
+                    break;
+                }
+                String[] ledgerIdAndEntryId = kvPair.getValue().split(":");
+                if (ledgerIdAndEntryId.length != 2 || !StringUtils.isNumeric(ledgerIdAndEntryId[0])
+                        || !StringUtils.isNumeric(ledgerIdAndEntryId[1])) {
+                    break;
+                }
+                pendingLId = Long.valueOf(ledgerIdAndEntryId[0]);
+                pendingEId = Long.valueOf(ledgerIdAndEntryId[1]);
+                break;
+            }
+        }
+
+        // Case-1: repeatedly publish. Source message was exactly resend by the Replicator after a cursor rewind.
+        //   - The first time: Replicator --M1--> producer --> ...
+        //   - Cursor rewind.
+        //   - The second time: Replicator --M1--> producer --> ...
+        if (pendingLId != null && pendingEId != null
+                && (pendingLId < lastPersistedSourceLedgerId || (pendingLId.longValue() == lastPersistedSourceLedgerId
+                  && pendingEId.longValue() <= lastPersistedSourceEntryId))) {
+            if (log.isDebugEnabled()) {
+                log.debug("[{}] [{}] Received an msg send receipt[pending send is repeated due to repl cursor rewind]:"
+                                + " source entry {}:{}, pending send: {}:{}, latest persisted: {}:{}",
+                        topic, producerName, sourceLId, sourceEId, pendingLId, pendingEId,
+                        lastPersistedSourceLedgerId, lastPersistedSourceEntryId);
+            }
+            removeAndApplyCallback(op, sourceLId, sourceEId, targetLId, targetEid, false);
+            ackReceived(cnx, sourceLId, sourceEId, targetLId, targetEid);
+            return;
+        }
+
+        // Case-2: repeatedly publish. Send command was executed again by the producer after a reconnect.
+        //  - Replicator --M1--> producer --> ...
+        //  - The first time: producer call Send-Command-1.
+        //  - Producer reconnect.
+        //  - The second time: producer call Send-Command-1.
+        if (sourceLId < lastPersistedSourceLedgerId
+                || (sourceLId == lastPersistedSourceLedgerId  && sourceEId <= lastPersistedSourceEntryId)) {
+            if (log.isDebugEnabled()) {
+                log.debug("[{}] [{}] Received an msg send receipt[repeated]: source entry {}:{}, latest persisted:"
+                                + " {}:{}",
+                        topic, producerName, sourceLId, sourceEId,
+                        lastPersistedSourceLedgerId, lastPersistedSourceEntryId);
+            }
+            return;
+        }
+
+        // Case-3, which is expected.
+        if (pendingLId != null && pendingEId != null && sourceLId == pendingLId.longValue()
+                && sourceEId == pendingEId.longValue()) {
+            if (log.isDebugEnabled()) {
+                log.debug("[{}] [{}] Received an msg send receipt[expected]: source entry {}:{}, target entry:"
+                                + " {}:{}",
+                        topic, producerName, sourceLId, sourceEId,
+                        targetLId, targetEid);
+            }
+            lastPersistedSourceLedgerId = sourceLId;
+            lastPersistedSourceEntryId = sourceEId;
+            removeAndApplyCallback(op, sourceLId, sourceEId, targetLId, targetEid, false);
+            return;
+        }
+
+        // Case-4: Unexpected
+        //   4-1: got null source cluster's entry position, which is unexpected.
+        //   4-2: unknown error, which is unexpected.
+        log.error("[{}] [{}] Received an msg send receipt[error]: source entry {}:{}, target entry: {}:{},"
+                + " pending send: {}:{}, latest persisted: {}:{}, queue-size: {}",
+                topic, producerName, sourceLId, sourceEId, targetLId, targetEid, pendingLId, pendingEId,
+                lastPersistedSourceLedgerId, lastPersistedSourceEntryId, pendingMessages.messagesCount());
+        cnx.channel().close();
+    }
+
+    protected void ackReceivedReplMarker(ClientCnx cnx, OpSendMsg op, long seq, long isSourceMarker,
+                                         long ledgerId, long entryId) {
+        // Case-1: repeatedly publish repl marker.
+        long lastSeqPersisted = LAST_SEQ_ID_PUBLISHED_UPDATER.get(this);
+        if (lastSeqPersisted != 0 && seq <= lastSeqPersisted) {
+            // Ignoring the ack since it's referring to a message that has already timed out.
+            if (log.isDebugEnabled()) {
+                log.debug("[{}] [{}] Received an repl marker send receipt[repeated]. seq: {}, seqPersisted: {},"
+                                + " isSourceMarker: {}, target entry: {}:{}",
+                        topic, producerName, seq, lastSeqPersisted, isSourceMarker, ledgerId, entryId);
+            }
+            return;
+        }
+
+        // Case-2, which is expected:
+        //   condition: broker responds SendReceipt who is a repl marker.
+        //   and condition: the current pending msg is also a marker.
+        boolean pendingMsgIsReplMarker = isReplicationMarker(op);
+        if (pendingMsgIsReplMarker && seq == op.sequenceId) {
+            if (log.isDebugEnabled()) {
+                log.debug("[{}] [{}] Received an repl marker send receipt[expected]. seq: {}, seqPersisted: {},"
+                                + " isReplMarker: {}, target entry: {}:{}",
+                        topic, producerName, seq, lastSeqPersisted, isSourceMarker, ledgerId, entryId);
+            }
+            long calculatedSeq = getHighestSequenceId(op);
+            LAST_SEQ_ID_PUBLISHED_UPDATER.getAndUpdate(this, last -> Math.max(last, calculatedSeq));
+            removeAndApplyCallback(op, seq, isSourceMarker, ledgerId, entryId, true);
+            return;
+        }
+
+        // Case-3, unexpected.
+        //   3-1: if "lastSeqPersisted < seq <= lastInProgressSend", rather than going here, it should be a SendError.
+        //   3-2: unknown error.
+        long lastInProgressSend = LAST_SEQ_ID_PUSHED_UPDATER.get(this);
+        String logText = String.format("[%s] [%s] Received an repl marker send receipt[error]. seq: %s, seqPending: %s."
+                + " sequenceIdPersisted: %s, lastInProgressSend: %s,"
+                + " isSourceMarker: %s, target entry: %s:%s, queue-size: %s",
+                topic, producerName, seq, pendingMsgIsReplMarker ? op.sequenceId : "unknown",
+                lastSeqPersisted, lastInProgressSend,
+                isSourceMarker, ledgerId, entryId, pendingMessages.messagesCount()
+        );
+        if (seq < lastInProgressSend) {
+            log.warn(logText);
+        } else {
+            log.error(logText);
+        }
+        // Force connection closing so that messages can be re-transmitted in a new connection.
+        cnx.channel().close();
+    }
+
+    private void removeAndApplyCallback(OpSendMsg op, long lIdSent, long eIdSent, long ledgerId, long entryId,
+                                        boolean isMarker) {
+        pendingMessages.remove();
+        releaseSemaphoreForSendOp(op);
+        // Since Geo-Replicator will not send batched message, skip to update the field
+        // "LAST_SEQ_ID_PUBLISHED_UPDATER".
+        op.setMessageId(ledgerId, entryId, partitionIndex);
+        try {
+            // Need to protect ourselves from any exception being thrown in the future handler from the
+            // application
+            op.sendComplete(null);
+        } catch (Throwable t) {
+            log.warn("[{}] [{}] Got exception while completing the callback for -- source-message: {}:{} --"
+                            + " target-msg: {}:{} -- isMarker: {}",
+                    topic, producerName, lIdSent, eIdSent, ledgerId, entryId, isMarker, t);
+        }
+        ReferenceCountUtil.safeRelease(op.cmd);
+        op.recycle();
+    }
+
+    private boolean isReplicationMarker(OpSendMsg op) {
+        return op.msg != null && op.msg.getMessageBuilder().hasMarkerType()
+                && Markers.isReplicationMarker(op.msg.getMessageBuilder().getMarkerType());
+    }
+
+    private boolean isReplicationMarker(long highestSeq) {
+        return Long.MIN_VALUE == highestSeq;
+    }
+
+    @Override
+    protected void updateLastSeqPushed(OpSendMsg op) {
+        // Only update the value for repl marker.
+        if (isReplicationMarker(op)) {
+            super.updateLastSeqPushed(op);
+        }
+    }
+}
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
index 6fd47e072f0..56055dd1631 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
@@ -109,7 +109,7 @@ public class ProducerImpl<T> extends ProducerBase<T> implements TimerTask, Conne
     // Variable is updated in a synchronized block
     private volatile long msgIdGenerator;
 
-    private final OpSendMsgQueue pendingMessages;
+    protected final OpSendMsgQueue pendingMessages;
     private final Optional<Semaphore> semaphore;
     private volatile Timeout sendTimeout = null;
     private final long lookupDeadline;
@@ -126,12 +126,12 @@ public class ProducerImpl<T> extends ProducerBase<T> implements TimerTask, Conne
     private LastSendFutureWrapper lastSendFutureWrapper = LastSendFutureWrapper.create(lastSendFuture);
 
     // Globally unique producer name
-    private String producerName;
+    protected String producerName;
     private final boolean userProvidedProducerName;
 
     private String connectionId;
     private String connectedSince;
-    private final int partitionIndex;
+    protected final int partitionIndex;
 
     private final ProducerStatsRecorder stats;
 
@@ -1199,7 +1199,7 @@ public class ProducerImpl<T> extends ProducerBase<T> implements TimerTask, Conne
         }
     }
 
-    void ackReceived(ClientCnx cnx, long sequenceId, long highestSequenceId, long ledgerId, long entryId) {
+    protected void ackReceived(ClientCnx cnx, long sequenceId, long highestSequenceId, long ledgerId, long entryId) {
         OpSendMsg op = null;
         synchronized (this) {
             op = pendingMessages.peek();
@@ -1274,11 +1274,11 @@ public class ProducerImpl<T> extends ProducerBase<T> implements TimerTask, Conne
         op.recycle();
     }
 
-    private long getHighestSequenceId(OpSendMsg op) {
+    protected long getHighestSequenceId(OpSendMsg op) {
         return Math.max(op.highestSequenceId, op.sequenceId);
     }
 
-    private void releaseSemaphoreForSendOp(OpSendMsg op) {
+    protected void releaseSemaphoreForSendOp(OpSendMsg op) {
 
         semaphoreRelease(isBatchMessagingEnabled() ? op.numMessagesInBatch : 1);
 
@@ -2272,10 +2272,7 @@ public class ProducerImpl<T> extends ProducerBase<T> implements TimerTask, Conne
                 return;
             }
             pendingMessages.add(op);
-            if (op.msg != null) {
-                LAST_SEQ_ID_PUSHED_UPDATER.getAndUpdate(this,
-                        last -> Math.max(last, getHighestSequenceId(op)));
-            }
+            updateLastSeqPushed(op);
 
             final ClientCnx cnx = getCnxIfReady();
             if (cnx != null) {
@@ -2301,6 +2298,13 @@ public class ProducerImpl<T> extends ProducerBase<T> implements TimerTask, Conne
         }
     }
 
+    protected void updateLastSeqPushed(OpSendMsg op) {
+        if (op.msg != null) {
+            LAST_SEQ_ID_PUSHED_UPDATER.getAndUpdate(this,
+                    last -> Math.max(last, getHighestSequenceId(op)));
+        }
+    }
+
     // Must acquire a lock on ProducerImpl.this before calling method.
     private void recoverProcessOpSendMsgFrom(ClientCnx cnx, MessageImpl from, long expectedEpoch) {
         if (expectedEpoch != this.connectionHandler.getEpoch() || cnx() == null) {
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java
index c5ec93bcdd2..cd9e6021c7e 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java
@@ -504,6 +504,10 @@ public class PulsarClientImpl implements PulsarClient {
                                                   ProducerInterceptors interceptors,
                                                   CompletableFuture<Producer<T>> producerCreatedFuture,
                                                   Optional<String> overrideProducerName) {
+        if (conf.isReplProducer()) {
+            return new GeoReplicationProducerImpl(PulsarClientImpl.this, topic, conf, producerCreatedFuture,
+                    partitionIndex, schema, interceptors, overrideProducerName);
+        }
         return new ProducerImpl<>(PulsarClientImpl.this, topic, conf, producerCreatedFuture, partitionIndex, schema,
                 interceptors, overrideProducerName);
     }
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ProducerConfigurationData.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ProducerConfigurationData.java
index 6ec738bbf4c..93261a3b7f6 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ProducerConfigurationData.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ProducerConfigurationData.java
@@ -206,6 +206,8 @@ public class ProducerConfigurationData implements Serializable, Cloneable {
 
     private boolean isNonPartitionedTopicExpected;
 
+    private boolean isReplProducer;
+
     @ApiModelProperty(
             name = "initialSubscriptionName",
             value = "Use this configuration to automatically create an initial subscription when creating a topic."
diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java b/pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
index 9fae9d1160e..c3e5fb8cb04 100644
--- a/pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
+++ b/pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
@@ -189,6 +189,7 @@ public class Commands {
         flags.setSupportsBrokerEntryMetadata(true);
         flags.setSupportsPartialProducer(true);
         flags.setSupportsGetPartitionedMetadataWithoutAutoCreation(true);
+        flags.setSupportsReplDedupByLidAndEid(true);
     }
 
     public static ByteBuf newConnect(String authMethodName, String authData, int protocolVersion, String libVersion,
@@ -242,6 +243,15 @@ public class Commands {
     public static ByteBuf newConnect(String authMethodName, AuthData authData, int protocolVersion, String libVersion,
                                      String targetBroker, String originalPrincipal, AuthData originalAuthData,
                                      String originalAuthMethod, String proxyVersion) {
+        BaseCommand cmd = newConnectWithoutSerialize(authMethodName, authData, protocolVersion, libVersion,
+                targetBroker, originalPrincipal, originalAuthData, originalAuthMethod, proxyVersion);
+        return serializeWithSize(cmd);
+    }
+
+    public static BaseCommand newConnectWithoutSerialize(String authMethodName, AuthData authData,
+                                    int protocolVersion, String libVersion,
+                                    String targetBroker, String originalPrincipal, AuthData originalAuthData,
+                                    String originalAuthMethod, String proxyVersion) {
         BaseCommand cmd = localCmd(Type.CONNECT);
         CommandConnect connect = cmd.setConnect()
                 .setClientVersion(libVersion != null ? libVersion : "Pulsar Client")
@@ -274,7 +284,7 @@ public class Commands {
         connect.setProtocolVersion(protocolVersion);
         setFeatureFlags(connect.setFeatureFlags());
 
-        return serializeWithSize(cmd);
+        return cmd;
     }
 
     public static ByteBuf newConnected(int clientProtocoVersion,  boolean supportsTopicWatchers) {
@@ -300,6 +310,7 @@ public class Commands {
 
         connected.setFeatureFlags().setSupportsTopicWatchers(supportsTopicWatchers);
         connected.setFeatureFlags().setSupportsGetPartitionedMetadataWithoutAutoCreation(true);
+        connected.setFeatureFlags().setSupportsReplDedupByLidAndEid(true);
         return cmd;
     }
 
diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Markers.java b/pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Markers.java
index 2291aee781f..de19b777ff0 100644
--- a/pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Markers.java
+++ b/pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Markers.java
@@ -18,6 +18,10 @@
  */
 package org.apache.pulsar.common.protocol;
 
+import static org.apache.pulsar.common.api.proto.MarkerType.REPLICATED_SUBSCRIPTION_SNAPSHOT;
+import static org.apache.pulsar.common.api.proto.MarkerType.REPLICATED_SUBSCRIPTION_SNAPSHOT_REQUEST;
+import static org.apache.pulsar.common.api.proto.MarkerType.REPLICATED_SUBSCRIPTION_SNAPSHOT_RESPONSE;
+import static org.apache.pulsar.common.api.proto.MarkerType.REPLICATED_SUBSCRIPTION_UPDATE;
 import io.netty.buffer.ByteBuf;
 import io.netty.util.concurrent.FastThreadLocal;
 import java.io.IOException;
@@ -98,6 +102,13 @@ public class Markers {
         return msgMetadata.hasMarkerType();
     }
 
+    public static boolean isReplicationMarker(int markerType) {
+        return markerType == REPLICATED_SUBSCRIPTION_SNAPSHOT_REQUEST.getValue()
+                || markerType == REPLICATED_SUBSCRIPTION_SNAPSHOT_RESPONSE.getValue()
+                || markerType == REPLICATED_SUBSCRIPTION_SNAPSHOT.getValue()
+                || markerType == REPLICATED_SUBSCRIPTION_UPDATE.getValue();
+    }
+
     public static boolean isReplicatedSubscriptionSnapshotMarker(MessageMetadata msgMetadata) {
         return msgMetadata != null
                 && msgMetadata.hasMarkerType()
diff --git a/pulsar-common/src/main/proto/PulsarApi.proto b/pulsar-common/src/main/proto/PulsarApi.proto
index fa2181b484f..eeddb4cdc65 100644
--- a/pulsar-common/src/main/proto/PulsarApi.proto
+++ b/pulsar-common/src/main/proto/PulsarApi.proto
@@ -302,6 +302,7 @@ message FeatureFlags {
   optional bool supports_partial_producer = 3 [default = false];
   optional bool supports_topic_watchers = 4 [default = false];
   optional bool supports_get_partitioned_metadata_without_auto_creation = 5 [default = false];
+  optional bool supports_repl_dedup_by_lid_and_eid = 6 [default = false];
 }
 
 message CommandConnected {


(pulsar) 13/15: [improve][ml] Use lock-free queue in InflightReadsLimiter since there's no concurrent access (#23962)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit e9cabbec8518f219462bd1b910ec5aef22c593d5
Author: guan46 <48...@users.noreply.github.com>
AuthorDate: Tue Feb 25 19:08:33 2025 +0800

    [improve][ml] Use lock-free queue in InflightReadsLimiter since there's no concurrent access  (#23962)
    
    (cherry picked from commit 38a41e0d29192d0e29cc172cccf6c187cf7cb542)
    (cherry picked from commit c237cb52b042c142822fffd64a654d1004365d0f)
---
 .../mledger/impl/cache/InflightReadsLimiter.java          | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/InflightReadsLimiter.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/InflightReadsLimiter.java
index 3a6bb3cd039..c2b9b82b694 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/InflightReadsLimiter.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/InflightReadsLimiter.java
@@ -20,13 +20,13 @@ package org.apache.bookkeeper.mledger.impl.cache;
 
 import com.google.common.annotations.VisibleForTesting;
 import io.prometheus.client.Gauge;
+import java.util.ArrayDeque;
 import java.util.Optional;
 import java.util.Queue;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Consumer;
 import lombok.extern.slf4j.Slf4j;
-import org.jctools.queues.SpscArrayQueue;
 
 @Slf4j
 public class InflightReadsLimiter {
@@ -37,6 +37,7 @@ public class InflightReadsLimiter {
             .help("Estimated number of bytes retained by data read from storage or cache")
             .register();
 
+    private final int maxReadsInFlightAcquireQueueSize;
     private static final Gauge PULSAR_ML_READS_AVAILABLE_BUFFER_SIZE = Gauge
             .build()
             .name("pulsar_ml_reads_available_inflight_bytes")
@@ -64,9 +65,10 @@ public class InflightReadsLimiter {
         this.remainingBytes = maxReadsInFlightSize;
         this.acquireTimeoutMillis = acquireTimeoutMillis;
         this.timeOutExecutor = timeOutExecutor;
+        this.maxReadsInFlightAcquireQueueSize = maxReadsInFlightAcquireQueueSize;
         if (maxReadsInFlightSize > 0) {
             enabled = true;
-            this.queuedHandles = new SpscArrayQueue<>(maxReadsInFlightAcquireQueueSize);
+            this.queuedHandles = new ArrayDeque<>();
         } else {
             enabled = false;
             this.queuedHandles = null;
@@ -129,13 +131,14 @@ public class InflightReadsLimiter {
             updateMetrics();
             return Optional.of(new Handle(maxReadsInFlightSize, handle.creationTime, true));
         } else {
-            if (queuedHandles.offer(new QueuedHandle(handle, callback))) {
-                scheduleTimeOutCheck(acquireTimeoutMillis);
-                return Optional.empty();
-            } else {
+            if (queuedHandles.size() >= maxReadsInFlightAcquireQueueSize) {
                 log.warn("Failed to queue handle for acquiring permits: {}, creationTime: {}, remainingBytes:{}",
                         permits, handle.creationTime, remainingBytes);
                 return Optional.of(new Handle(0, handle.creationTime, false));
+            } else {
+                queuedHandles.offer(new QueuedHandle(handle, callback));
+                scheduleTimeOutCheck(acquireTimeoutMillis);
+                return Optional.empty();
             }
         }
     }


(pulsar) 10/15: [fix][test]Fix flaky test V1_ProducerConsumerTest.testConcurrentConsumerReceiveWhileReconnect (#24019)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit a496176da7f0d11e7d731fad01fb751e0a11209b
Author: fengyubiao <yu...@streamnative.io>
AuthorDate: Tue Feb 25 14:48:55 2025 +0800

    [fix][test]Fix flaky test V1_ProducerConsumerTest.testConcurrentConsumerReceiveWhileReconnect (#24019)
    
    (cherry picked from commit 2c686d0ab1ea3f697dea4f5ce7938282b9b06f88)
    (cherry picked from commit cd8640b6b94538e28e5e642fa28b8616e198e19e)
---
 .../org/apache/pulsar/client/api/v1/V1_ProducerConsumerTest.java  | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/v1/V1_ProducerConsumerTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/v1/V1_ProducerConsumerTest.java
index e126d963a88..d25041e1dfc 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/v1/V1_ProducerConsumerTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/v1/V1_ProducerConsumerTest.java
@@ -589,9 +589,11 @@ public class V1_ProducerConsumerTest extends V1_ProducerConsumerBase {
         restartBroker();
 
         // The available permits should be 10 and num messages in the queue should be 90
-        Awaitility.await().untilAsserted(() ->
-                Assert.assertEquals(consumerImpl.getAvailablePermits(), numConsumersThreads));
-        Assert.assertEquals(consumerImpl.numMessagesInQueue(), recvQueueSize - numConsumersThreads);
+        Awaitility.await().untilAsserted(() -> {
+            Assert.assertEquals(consumerImpl.getAvailablePermits(), numConsumersThreads);
+            Assert.assertEquals(consumerImpl.numMessagesInQueue(), recvQueueSize - numConsumersThreads);
+        });
+
         consumer.close();
     }
 


(pulsar) 14/15: Bump version to next snapshot version

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 9b888374b665bf72eb15264a8c3effa73efbe2bc
Author: Lari Hotari <lh...@apache.org>
AuthorDate: Thu Feb 27 15:07:00 2025 +0200

    Bump version to next snapshot version
    
    (cherry picked from commit 8437af98eb74e3d7bca959813c7d04d1414140e5)
---
 bouncy-castle/bc/pom.xml                              | 2 +-
 bouncy-castle/bcfips-include-test/pom.xml             | 2 +-
 bouncy-castle/bcfips/pom.xml                          | 2 +-
 bouncy-castle/pom.xml                                 | 2 +-
 buildtools/pom.xml                                    | 4 ++--
 distribution/io/pom.xml                               | 2 +-
 distribution/offloaders/pom.xml                       | 2 +-
 distribution/pom.xml                                  | 2 +-
 distribution/server/pom.xml                           | 2 +-
 distribution/shell/pom.xml                            | 2 +-
 docker/pom.xml                                        | 2 +-
 docker/pulsar-all/pom.xml                             | 2 +-
 docker/pulsar/pom.xml                                 | 2 +-
 jclouds-shaded/pom.xml                                | 2 +-
 jetcd-core-shaded/pom.xml                             | 2 +-
 managed-ledger/pom.xml                                | 2 +-
 pom.xml                                               | 4 ++--
 pulsar-broker-auth-athenz/pom.xml                     | 2 +-
 pulsar-broker-auth-oidc/pom.xml                       | 2 +-
 pulsar-broker-auth-sasl/pom.xml                       | 2 +-
 pulsar-broker-common/pom.xml                          | 2 +-
 pulsar-broker/pom.xml                                 | 2 +-
 pulsar-client-1x-base/pom.xml                         | 2 +-
 pulsar-client-1x-base/pulsar-client-1x/pom.xml        | 2 +-
 pulsar-client-1x-base/pulsar-client-2x-shaded/pom.xml | 2 +-
 pulsar-client-admin-api/pom.xml                       | 2 +-
 pulsar-client-admin-shaded/pom.xml                    | 2 +-
 pulsar-client-admin/pom.xml                           | 2 +-
 pulsar-client-all/pom.xml                             | 2 +-
 pulsar-client-api/pom.xml                             | 2 +-
 pulsar-client-auth-athenz/pom.xml                     | 2 +-
 pulsar-client-auth-sasl/pom.xml                       | 2 +-
 pulsar-client-messagecrypto-bc/pom.xml                | 2 +-
 pulsar-client-shaded/pom.xml                          | 2 +-
 pulsar-client-tools-api/pom.xml                       | 2 +-
 pulsar-client-tools-customcommand-example/pom.xml     | 2 +-
 pulsar-client-tools-test/pom.xml                      | 2 +-
 pulsar-client-tools/pom.xml                           | 2 +-
 pulsar-client/pom.xml                                 | 2 +-
 pulsar-common/pom.xml                                 | 2 +-
 pulsar-config-validation/pom.xml                      | 2 +-
 pulsar-functions/api-java/pom.xml                     | 2 +-
 pulsar-functions/instance/pom.xml                     | 2 +-
 pulsar-functions/java-examples-builtin/pom.xml        | 2 +-
 pulsar-functions/java-examples/pom.xml                | 2 +-
 pulsar-functions/localrun-shaded/pom.xml              | 2 +-
 pulsar-functions/localrun/pom.xml                     | 2 +-
 pulsar-functions/pom.xml                              | 2 +-
 pulsar-functions/proto/pom.xml                        | 2 +-
 pulsar-functions/runtime-all/pom.xml                  | 2 +-
 pulsar-functions/runtime/pom.xml                      | 2 +-
 pulsar-functions/secrets/pom.xml                      | 2 +-
 pulsar-functions/utils/pom.xml                        | 2 +-
 pulsar-functions/worker/pom.xml                       | 2 +-
 pulsar-io/aerospike/pom.xml                           | 2 +-
 pulsar-io/alluxio/pom.xml                             | 2 +-
 pulsar-io/aws/pom.xml                                 | 2 +-
 pulsar-io/batch-data-generator/pom.xml                | 2 +-
 pulsar-io/batch-discovery-triggerers/pom.xml          | 2 +-
 pulsar-io/canal/pom.xml                               | 2 +-
 pulsar-io/cassandra/pom.xml                           | 2 +-
 pulsar-io/common/pom.xml                              | 2 +-
 pulsar-io/core/pom.xml                                | 2 +-
 pulsar-io/data-generator/pom.xml                      | 2 +-
 pulsar-io/debezium/core/pom.xml                       | 2 +-
 pulsar-io/debezium/mongodb/pom.xml                    | 2 +-
 pulsar-io/debezium/mssql/pom.xml                      | 2 +-
 pulsar-io/debezium/mysql/pom.xml                      | 2 +-
 pulsar-io/debezium/oracle/pom.xml                     | 2 +-
 pulsar-io/debezium/pom.xml                            | 2 +-
 pulsar-io/debezium/postgres/pom.xml                   | 2 +-
 pulsar-io/docs/pom.xml                                | 2 +-
 pulsar-io/dynamodb/pom.xml                            | 2 +-
 pulsar-io/elastic-search/pom.xml                      | 2 +-
 pulsar-io/file/pom.xml                                | 2 +-
 pulsar-io/flume/pom.xml                               | 2 +-
 pulsar-io/hbase/pom.xml                               | 2 +-
 pulsar-io/hdfs2/pom.xml                               | 2 +-
 pulsar-io/hdfs3/pom.xml                               | 2 +-
 pulsar-io/http/pom.xml                                | 2 +-
 pulsar-io/influxdb/pom.xml                            | 2 +-
 pulsar-io/jdbc/clickhouse/pom.xml                     | 2 +-
 pulsar-io/jdbc/core/pom.xml                           | 2 +-
 pulsar-io/jdbc/mariadb/pom.xml                        | 2 +-
 pulsar-io/jdbc/openmldb/pom.xml                       | 2 +-
 pulsar-io/jdbc/pom.xml                                | 2 +-
 pulsar-io/jdbc/postgres/pom.xml                       | 2 +-
 pulsar-io/jdbc/sqlite/pom.xml                         | 2 +-
 pulsar-io/kafka-connect-adaptor-nar/pom.xml           | 2 +-
 pulsar-io/kafka-connect-adaptor/pom.xml               | 2 +-
 pulsar-io/kafka/pom.xml                               | 2 +-
 pulsar-io/kinesis/pom.xml                             | 2 +-
 pulsar-io/mongo/pom.xml                               | 2 +-
 pulsar-io/netty/pom.xml                               | 2 +-
 pulsar-io/nsq/pom.xml                                 | 2 +-
 pulsar-io/pom.xml                                     | 2 +-
 pulsar-io/rabbitmq/pom.xml                            | 2 +-
 pulsar-io/redis/pom.xml                               | 2 +-
 pulsar-io/solr/pom.xml                                | 2 +-
 pulsar-io/twitter/pom.xml                             | 2 +-
 pulsar-metadata/pom.xml                               | 2 +-
 pulsar-package-management/bookkeeper-storage/pom.xml  | 2 +-
 pulsar-package-management/core/pom.xml                | 2 +-
 pulsar-package-management/filesystem-storage/pom.xml  | 2 +-
 pulsar-package-management/pom.xml                     | 2 +-
 pulsar-proxy/pom.xml                                  | 2 +-
 pulsar-sql/pom.xml                                    | 2 +-
 pulsar-sql/presto-distribution/pom.xml                | 2 +-
 pulsar-sql/presto-pulsar-plugin/pom.xml               | 2 +-
 pulsar-sql/presto-pulsar/pom.xml                      | 2 +-
 pulsar-testclient/pom.xml                             | 2 +-
 pulsar-transaction/common/pom.xml                     | 2 +-
 pulsar-transaction/coordinator/pom.xml                | 2 +-
 pulsar-transaction/pom.xml                            | 2 +-
 pulsar-websocket/pom.xml                              | 2 +-
 structured-event-log/pom.xml                          | 2 +-
 testmocks/pom.xml                                     | 2 +-
 tests/bc_2_0_0/pom.xml                                | 2 +-
 tests/bc_2_0_1/pom.xml                                | 2 +-
 tests/bc_2_6_0/pom.xml                                | 2 +-
 tests/docker-images/java-test-functions/pom.xml       | 2 +-
 tests/docker-images/java-test-image/pom.xml           | 2 +-
 tests/docker-images/java-test-plugins/pom.xml         | 2 +-
 tests/docker-images/latest-version-image/pom.xml      | 2 +-
 tests/docker-images/pom.xml                           | 2 +-
 tests/integration/pom.xml                             | 2 +-
 tests/pom.xml                                         | 2 +-
 tests/pulsar-client-admin-shade-test/pom.xml          | 2 +-
 tests/pulsar-client-all-shade-test/pom.xml            | 2 +-
 tests/pulsar-client-shade-test/pom.xml                | 2 +-
 tiered-storage/file-system/pom.xml                    | 2 +-
 tiered-storage/jcloud/pom.xml                         | 2 +-
 tiered-storage/pom.xml                                | 2 +-
 133 files changed, 135 insertions(+), 135 deletions(-)

diff --git a/bouncy-castle/bc/pom.xml b/bouncy-castle/bc/pom.xml
index 9ce7bb20881..c66697b77a8 100644
--- a/bouncy-castle/bc/pom.xml
+++ b/bouncy-castle/bc/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>bouncy-castle-parent</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/bouncy-castle/bcfips-include-test/pom.xml b/bouncy-castle/bcfips-include-test/pom.xml
index d3eb9ba158c..c639382b438 100644
--- a/bouncy-castle/bcfips-include-test/pom.xml
+++ b/bouncy-castle/bcfips-include-test/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>bouncy-castle-parent</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/bouncy-castle/bcfips/pom.xml b/bouncy-castle/bcfips/pom.xml
index 6f6d73dbcbc..cf204d8c473 100644
--- a/bouncy-castle/bcfips/pom.xml
+++ b/bouncy-castle/bcfips/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>bouncy-castle-parent</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/bouncy-castle/pom.xml b/bouncy-castle/pom.xml
index 61283fc5ec8..2d62580a5f4 100644
--- a/bouncy-castle/pom.xml
+++ b/bouncy-castle/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/buildtools/pom.xml b/buildtools/pom.xml
index 0b8a9107186..e4d0a9740bc 100644
--- a/buildtools/pom.xml
+++ b/buildtools/pom.xml
@@ -31,7 +31,7 @@
 
   <groupId>org.apache.pulsar</groupId>
   <artifactId>buildtools</artifactId>
-  <version>3.0.10</version>
+  <version>3.0.11-SNAPSHOT</version>
   <packaging>jar</packaging>
   <name>Pulsar Build Tools</name>
 
@@ -43,7 +43,7 @@
   </developers>
 
   <properties>
-    <project.build.outputTimestamp>2025-02-19T19:41:21Z</project.build.outputTimestamp>
+    <project.build.outputTimestamp>2025-02-27T13:06:59Z</project.build.outputTimestamp>
     <maven.compiler.source>1.8</maven.compiler.source>
     <maven.compiler.target>1.8</maven.compiler.target>
     <surefire.version>3.1.0</surefire.version>
diff --git a/distribution/io/pom.xml b/distribution/io/pom.xml
index 0f461b6df7b..7fe2efd10cb 100644
--- a/distribution/io/pom.xml
+++ b/distribution/io/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>distribution</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/distribution/offloaders/pom.xml b/distribution/offloaders/pom.xml
index 652292ff695..602430b6324 100644
--- a/distribution/offloaders/pom.xml
+++ b/distribution/offloaders/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>distribution</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/distribution/pom.xml b/distribution/pom.xml
index d176aa56485..a2d3848dbec 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/distribution/server/pom.xml b/distribution/server/pom.xml
index 2d80d3f607a..e64328b5ab9 100644
--- a/distribution/server/pom.xml
+++ b/distribution/server/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>distribution</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/distribution/shell/pom.xml b/distribution/shell/pom.xml
index 35c8a90e439..ded63137d49 100644
--- a/distribution/shell/pom.xml
+++ b/distribution/shell/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>distribution</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/docker/pom.xml b/docker/pom.xml
index 3dcc0ad2b0f..bde1db49a1a 100644
--- a/docker/pom.xml
+++ b/docker/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <artifactId>docker-images</artifactId>
   <name>Apache Pulsar :: Docker Images</name>
diff --git a/docker/pulsar-all/pom.xml b/docker/pulsar-all/pom.xml
index 4349bd0d471..9e6bc7398cb 100644
--- a/docker/pulsar-all/pom.xml
+++ b/docker/pulsar-all/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>docker-images</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>pulsar-all-docker-image</artifactId>
diff --git a/docker/pulsar/pom.xml b/docker/pulsar/pom.xml
index c1c40f846b8..e7e1b039103 100644
--- a/docker/pulsar/pom.xml
+++ b/docker/pulsar/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>docker-images</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>pulsar-docker-image</artifactId>
diff --git a/jclouds-shaded/pom.xml b/jclouds-shaded/pom.xml
index 5271cc6f2d5..ed280f88de7 100644
--- a/jclouds-shaded/pom.xml
+++ b/jclouds-shaded/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/jetcd-core-shaded/pom.xml b/jetcd-core-shaded/pom.xml
index 4af4aad4eda..51049ff9f62 100644
--- a/jetcd-core-shaded/pom.xml
+++ b/jetcd-core-shaded/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>jetcd-core-shaded</artifactId>
diff --git a/managed-ledger/pom.xml b/managed-ledger/pom.xml
index c44dbb30d21..543668a5bb0 100644
--- a/managed-ledger/pom.xml
+++ b/managed-ledger/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pom.xml b/pom.xml
index 9a01ee522cc..299f947478e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
   <groupId>org.apache.pulsar</groupId>
   <artifactId>pulsar</artifactId>
 
-  <version>3.0.10</version>
+  <version>3.0.11-SNAPSHOT</version>
 
   <name>Pulsar</name>
   <description>Pulsar is a distributed pub-sub messaging platform with a very
@@ -95,7 +95,7 @@ flexible messaging model and an intuitive client API.</description>
 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-    <project.build.outputTimestamp>2025-02-19T19:41:21Z</project.build.outputTimestamp>
+    <project.build.outputTimestamp>2025-02-27T13:06:59Z</project.build.outputTimestamp>
     <redirectTestOutputToFile>true</redirectTestOutputToFile>
 
     <!-- By default build for local Docker platform.
diff --git a/pulsar-broker-auth-athenz/pom.xml b/pulsar-broker-auth-athenz/pom.xml
index e1730fa960d..0ea9fc20d39 100644
--- a/pulsar-broker-auth-athenz/pom.xml
+++ b/pulsar-broker-auth-athenz/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-broker-auth-athenz</artifactId>
diff --git a/pulsar-broker-auth-oidc/pom.xml b/pulsar-broker-auth-oidc/pom.xml
index 52fcc61d944..bbbf32b1ba2 100644
--- a/pulsar-broker-auth-oidc/pom.xml
+++ b/pulsar-broker-auth-oidc/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-broker-auth-oidc</artifactId>
diff --git a/pulsar-broker-auth-sasl/pom.xml b/pulsar-broker-auth-sasl/pom.xml
index b733d5de963..d544f3fd007 100644
--- a/pulsar-broker-auth-sasl/pom.xml
+++ b/pulsar-broker-auth-sasl/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-broker-auth-sasl</artifactId>
diff --git a/pulsar-broker-common/pom.xml b/pulsar-broker-common/pom.xml
index aef72d183d8..39cbc8873ec 100644
--- a/pulsar-broker-common/pom.xml
+++ b/pulsar-broker-common/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-broker-common</artifactId>
diff --git a/pulsar-broker/pom.xml b/pulsar-broker/pom.xml
index 75932f2de07..6c0c6d55b60 100644
--- a/pulsar-broker/pom.xml
+++ b/pulsar-broker/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-client-1x-base/pom.xml b/pulsar-client-1x-base/pom.xml
index 2603c68f1c6..51aea6e0b70 100644
--- a/pulsar-client-1x-base/pom.xml
+++ b/pulsar-client-1x-base/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-client-1x-base/pulsar-client-1x/pom.xml b/pulsar-client-1x-base/pulsar-client-1x/pom.xml
index bf52abc3c9b..e8b18d3ec0c 100644
--- a/pulsar-client-1x-base/pulsar-client-1x/pom.xml
+++ b/pulsar-client-1x-base/pulsar-client-1x/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-client-1x-base</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-client-1x-base/pulsar-client-2x-shaded/pom.xml b/pulsar-client-1x-base/pulsar-client-2x-shaded/pom.xml
index 53a6fa9463e..bcfba85b590 100644
--- a/pulsar-client-1x-base/pulsar-client-2x-shaded/pom.xml
+++ b/pulsar-client-1x-base/pulsar-client-2x-shaded/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-client-1x-base</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-client-admin-api/pom.xml b/pulsar-client-admin-api/pom.xml
index f250a932a93..92de4e8cfdb 100644
--- a/pulsar-client-admin-api/pom.xml
+++ b/pulsar-client-admin-api/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
diff --git a/pulsar-client-admin-shaded/pom.xml b/pulsar-client-admin-shaded/pom.xml
index 701cae6764e..ef8d7cffb54 100644
--- a/pulsar-client-admin-shaded/pom.xml
+++ b/pulsar-client-admin-shaded/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
   <artifactId>pulsar-client-admin</artifactId>
diff --git a/pulsar-client-admin/pom.xml b/pulsar-client-admin/pom.xml
index fa99c7e870f..c0890e8d325 100644
--- a/pulsar-client-admin/pom.xml
+++ b/pulsar-client-admin/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-client-all/pom.xml b/pulsar-client-all/pom.xml
index d7e41dd6c44..867ba8c4ad9 100644
--- a/pulsar-client-all/pom.xml
+++ b/pulsar-client-all/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
   <artifactId>pulsar-client-all</artifactId>
diff --git a/pulsar-client-api/pom.xml b/pulsar-client-api/pom.xml
index 82b927f1293..3c8474eef2a 100644
--- a/pulsar-client-api/pom.xml
+++ b/pulsar-client-api/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
diff --git a/pulsar-client-auth-athenz/pom.xml b/pulsar-client-auth-athenz/pom.xml
index cacdb8edec8..f6428248b64 100644
--- a/pulsar-client-auth-athenz/pom.xml
+++ b/pulsar-client-auth-athenz/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-client-auth-sasl/pom.xml b/pulsar-client-auth-sasl/pom.xml
index 7f79d3e936d..39ae61194fd 100644
--- a/pulsar-client-auth-sasl/pom.xml
+++ b/pulsar-client-auth-sasl/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-client-messagecrypto-bc/pom.xml b/pulsar-client-messagecrypto-bc/pom.xml
index d7cc76dd867..621777ce112 100644
--- a/pulsar-client-messagecrypto-bc/pom.xml
+++ b/pulsar-client-messagecrypto-bc/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-client-shaded/pom.xml b/pulsar-client-shaded/pom.xml
index 85a684588de..740e557a2fb 100644
--- a/pulsar-client-shaded/pom.xml
+++ b/pulsar-client-shaded/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
   <artifactId>pulsar-client</artifactId>
diff --git a/pulsar-client-tools-api/pom.xml b/pulsar-client-tools-api/pom.xml
index a1dd0c1d28a..bebae84b221 100644
--- a/pulsar-client-tools-api/pom.xml
+++ b/pulsar-client-tools-api/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-client-tools-customcommand-example/pom.xml b/pulsar-client-tools-customcommand-example/pom.xml
index 62b5aa58288..5e0a31cc72e 100644
--- a/pulsar-client-tools-customcommand-example/pom.xml
+++ b/pulsar-client-tools-customcommand-example/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
   <modelVersion>4.0.0</modelVersion>
diff --git a/pulsar-client-tools-test/pom.xml b/pulsar-client-tools-test/pom.xml
index 8afeb1f535f..b8fadb708f6 100644
--- a/pulsar-client-tools-test/pom.xml
+++ b/pulsar-client-tools-test/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-client-tools/pom.xml b/pulsar-client-tools/pom.xml
index 77d1a1ef766..205aca8bd0c 100644
--- a/pulsar-client-tools/pom.xml
+++ b/pulsar-client-tools/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-client/pom.xml b/pulsar-client/pom.xml
index 9335fe36253..4fa1bc3e780 100644
--- a/pulsar-client/pom.xml
+++ b/pulsar-client/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-common/pom.xml b/pulsar-common/pom.xml
index 5c88ceb00c1..36e8f51f294 100644
--- a/pulsar-common/pom.xml
+++ b/pulsar-common/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-config-validation/pom.xml b/pulsar-config-validation/pom.xml
index 1522883dbc3..79091261fe8 100644
--- a/pulsar-config-validation/pom.xml
+++ b/pulsar-config-validation/pom.xml
@@ -26,7 +26,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
diff --git a/pulsar-functions/api-java/pom.xml b/pulsar-functions/api-java/pom.xml
index c290def18a5..c27910d7fdc 100644
--- a/pulsar-functions/api-java/pom.xml
+++ b/pulsar-functions/api-java/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-functions</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-functions-api</artifactId>
diff --git a/pulsar-functions/instance/pom.xml b/pulsar-functions/instance/pom.xml
index 7e5e613c07e..e4f5965157a 100644
--- a/pulsar-functions/instance/pom.xml
+++ b/pulsar-functions/instance/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-functions</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-functions-instance</artifactId>
diff --git a/pulsar-functions/java-examples-builtin/pom.xml b/pulsar-functions/java-examples-builtin/pom.xml
index e9aec45c67b..05cce8a9d66 100644
--- a/pulsar-functions/java-examples-builtin/pom.xml
+++ b/pulsar-functions/java-examples-builtin/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-functions</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-functions-api-examples-builtin</artifactId>
diff --git a/pulsar-functions/java-examples/pom.xml b/pulsar-functions/java-examples/pom.xml
index f49bf69341d..c8dd70a655f 100644
--- a/pulsar-functions/java-examples/pom.xml
+++ b/pulsar-functions/java-examples/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-functions</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-functions-api-examples</artifactId>
diff --git a/pulsar-functions/localrun-shaded/pom.xml b/pulsar-functions/localrun-shaded/pom.xml
index 37840909fb3..bb7dbd1c4ce 100644
--- a/pulsar-functions/localrun-shaded/pom.xml
+++ b/pulsar-functions/localrun-shaded/pom.xml
@@ -26,7 +26,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-functions</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
diff --git a/pulsar-functions/localrun/pom.xml b/pulsar-functions/localrun/pom.xml
index 8b6cc73c181..ff6ad0bf92d 100644
--- a/pulsar-functions/localrun/pom.xml
+++ b/pulsar-functions/localrun/pom.xml
@@ -26,7 +26,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-functions</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
diff --git a/pulsar-functions/pom.xml b/pulsar-functions/pom.xml
index 78cc38debd9..6d07bbacd7b 100644
--- a/pulsar-functions/pom.xml
+++ b/pulsar-functions/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-functions</artifactId>
diff --git a/pulsar-functions/proto/pom.xml b/pulsar-functions/proto/pom.xml
index 5f619aee073..f977f79d72f 100644
--- a/pulsar-functions/proto/pom.xml
+++ b/pulsar-functions/proto/pom.xml
@@ -27,7 +27,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-functions</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-functions-proto</artifactId>
diff --git a/pulsar-functions/runtime-all/pom.xml b/pulsar-functions/runtime-all/pom.xml
index 6f325d6ad65..11fe654ad14 100644
--- a/pulsar-functions/runtime-all/pom.xml
+++ b/pulsar-functions/runtime-all/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-functions</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-functions/runtime/pom.xml b/pulsar-functions/runtime/pom.xml
index c997c432362..630b6322fd9 100644
--- a/pulsar-functions/runtime/pom.xml
+++ b/pulsar-functions/runtime/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-functions</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-functions-runtime</artifactId>
diff --git a/pulsar-functions/secrets/pom.xml b/pulsar-functions/secrets/pom.xml
index 99ab6379758..760661b2bcb 100644
--- a/pulsar-functions/secrets/pom.xml
+++ b/pulsar-functions/secrets/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-functions</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-functions-secrets</artifactId>
diff --git a/pulsar-functions/utils/pom.xml b/pulsar-functions/utils/pom.xml
index d8caa441ea5..73341aee9f8 100644
--- a/pulsar-functions/utils/pom.xml
+++ b/pulsar-functions/utils/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-functions</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-functions-utils</artifactId>
diff --git a/pulsar-functions/worker/pom.xml b/pulsar-functions/worker/pom.xml
index b9303bbbf00..599f042f352 100644
--- a/pulsar-functions/worker/pom.xml
+++ b/pulsar-functions/worker/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-functions</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-io/aerospike/pom.xml b/pulsar-io/aerospike/pom.xml
index 6108ae7cb18..dc4a211bc5c 100644
--- a/pulsar-io/aerospike/pom.xml
+++ b/pulsar-io/aerospike/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-aerospike</artifactId>
diff --git a/pulsar-io/alluxio/pom.xml b/pulsar-io/alluxio/pom.xml
index a368efb918b..1df18958084 100644
--- a/pulsar-io/alluxio/pom.xml
+++ b/pulsar-io/alluxio/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>pulsar-io</artifactId>
         <groupId>org.apache.pulsar</groupId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <properties>
diff --git a/pulsar-io/aws/pom.xml b/pulsar-io/aws/pom.xml
index 3643bdb8a04..7869dc56f80 100644
--- a/pulsar-io/aws/pom.xml
+++ b/pulsar-io/aws/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-aws</artifactId>
diff --git a/pulsar-io/batch-data-generator/pom.xml b/pulsar-io/batch-data-generator/pom.xml
index 183443b6b7a..5cbaa952c78 100644
--- a/pulsar-io/batch-data-generator/pom.xml
+++ b/pulsar-io/batch-data-generator/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-io</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-io-batch-data-generator</artifactId>
diff --git a/pulsar-io/batch-discovery-triggerers/pom.xml b/pulsar-io/batch-discovery-triggerers/pom.xml
index ac2869dc4e7..a96fc809565 100644
--- a/pulsar-io/batch-discovery-triggerers/pom.xml
+++ b/pulsar-io/batch-discovery-triggerers/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-batch-discovery-triggerers</artifactId>
diff --git a/pulsar-io/canal/pom.xml b/pulsar-io/canal/pom.xml
index d81f191aa9b..24121d7d05d 100644
--- a/pulsar-io/canal/pom.xml
+++ b/pulsar-io/canal/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-io</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
diff --git a/pulsar-io/cassandra/pom.xml b/pulsar-io/cassandra/pom.xml
index 234990ebd92..9b34aac95fe 100644
--- a/pulsar-io/cassandra/pom.xml
+++ b/pulsar-io/cassandra/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-cassandra</artifactId>
diff --git a/pulsar-io/common/pom.xml b/pulsar-io/common/pom.xml
index bd74815665f..6d590386bb7 100644
--- a/pulsar-io/common/pom.xml
+++ b/pulsar-io/common/pom.xml
@@ -27,7 +27,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-io</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-io-common</artifactId>
diff --git a/pulsar-io/core/pom.xml b/pulsar-io/core/pom.xml
index aa023082f13..a172b273592 100644
--- a/pulsar-io/core/pom.xml
+++ b/pulsar-io/core/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-core</artifactId>
diff --git a/pulsar-io/data-generator/pom.xml b/pulsar-io/data-generator/pom.xml
index 785cf4d552e..3dc390a2aab 100644
--- a/pulsar-io/data-generator/pom.xml
+++ b/pulsar-io/data-generator/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-io</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-io-data-generator</artifactId>
diff --git a/pulsar-io/debezium/core/pom.xml b/pulsar-io/debezium/core/pom.xml
index a10670d3025..700acd47828 100644
--- a/pulsar-io/debezium/core/pom.xml
+++ b/pulsar-io/debezium/core/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io-debezium</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-debezium-core</artifactId>
diff --git a/pulsar-io/debezium/mongodb/pom.xml b/pulsar-io/debezium/mongodb/pom.xml
index 6c8d5a96fb4..ec190490e56 100644
--- a/pulsar-io/debezium/mongodb/pom.xml
+++ b/pulsar-io/debezium/mongodb/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-io-debezium</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-io-debezium-mongodb</artifactId>
diff --git a/pulsar-io/debezium/mssql/pom.xml b/pulsar-io/debezium/mssql/pom.xml
index b0e809b7f42..2d8bae9710b 100644
--- a/pulsar-io/debezium/mssql/pom.xml
+++ b/pulsar-io/debezium/mssql/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io-debezium</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-debezium-mssql</artifactId>
diff --git a/pulsar-io/debezium/mysql/pom.xml b/pulsar-io/debezium/mysql/pom.xml
index 8a326b74295..80957060924 100644
--- a/pulsar-io/debezium/mysql/pom.xml
+++ b/pulsar-io/debezium/mysql/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io-debezium</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-debezium-mysql</artifactId>
diff --git a/pulsar-io/debezium/oracle/pom.xml b/pulsar-io/debezium/oracle/pom.xml
index 25dea2eef8d..a626e6baeb5 100644
--- a/pulsar-io/debezium/oracle/pom.xml
+++ b/pulsar-io/debezium/oracle/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io-debezium</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-debezium-oracle</artifactId>
diff --git a/pulsar-io/debezium/pom.xml b/pulsar-io/debezium/pom.xml
index 52b619e61a5..d84a77a1b26 100644
--- a/pulsar-io/debezium/pom.xml
+++ b/pulsar-io/debezium/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-debezium</artifactId>
diff --git a/pulsar-io/debezium/postgres/pom.xml b/pulsar-io/debezium/postgres/pom.xml
index f1241146cb6..d9d957f3e58 100644
--- a/pulsar-io/debezium/postgres/pom.xml
+++ b/pulsar-io/debezium/postgres/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io-debezium</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-debezium-postgres</artifactId>
diff --git a/pulsar-io/docs/pom.xml b/pulsar-io/docs/pom.xml
index 557bf28e1a7..55c591004a4 100644
--- a/pulsar-io/docs/pom.xml
+++ b/pulsar-io/docs/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-docs</artifactId>
diff --git a/pulsar-io/dynamodb/pom.xml b/pulsar-io/dynamodb/pom.xml
index 2af4155f44b..9e2546ec52c 100644
--- a/pulsar-io/dynamodb/pom.xml
+++ b/pulsar-io/dynamodb/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-dynamodb</artifactId>
diff --git a/pulsar-io/elastic-search/pom.xml b/pulsar-io/elastic-search/pom.xml
index ea1f4cd28e3..8137bd829d3 100644
--- a/pulsar-io/elastic-search/pom.xml
+++ b/pulsar-io/elastic-search/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <artifactId>pulsar-io-elastic-search</artifactId>
   <name>Pulsar IO :: ElasticSearch</name>
diff --git a/pulsar-io/file/pom.xml b/pulsar-io/file/pom.xml
index 557f6a6903b..5eb41f85b21 100644
--- a/pulsar-io/file/pom.xml
+++ b/pulsar-io/file/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-file</artifactId>
diff --git a/pulsar-io/flume/pom.xml b/pulsar-io/flume/pom.xml
index dc5a0734e18..940978fee19 100644
--- a/pulsar-io/flume/pom.xml
+++ b/pulsar-io/flume/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-io</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-io-flume</artifactId>
diff --git a/pulsar-io/hbase/pom.xml b/pulsar-io/hbase/pom.xml
index 50bd48a852e..d849a98ff26 100644
--- a/pulsar-io/hbase/pom.xml
+++ b/pulsar-io/hbase/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>pulsar-io</artifactId>
         <groupId>org.apache.pulsar</groupId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
     <artifactId>pulsar-io-hbase</artifactId>
     <name>Pulsar IO :: Hbase</name>
diff --git a/pulsar-io/hdfs2/pom.xml b/pulsar-io/hdfs2/pom.xml
index 89e3d3d3fdd..3448f4199bb 100644
--- a/pulsar-io/hdfs2/pom.xml
+++ b/pulsar-io/hdfs2/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <artifactId>pulsar-io-hdfs2</artifactId>
   <name>Pulsar IO :: Hdfs2</name>
diff --git a/pulsar-io/hdfs3/pom.xml b/pulsar-io/hdfs3/pom.xml
index d54e54f3c80..7cba35291cd 100644
--- a/pulsar-io/hdfs3/pom.xml
+++ b/pulsar-io/hdfs3/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <artifactId>pulsar-io-hdfs3</artifactId>
   <name>Pulsar IO :: Hdfs3</name>
diff --git a/pulsar-io/http/pom.xml b/pulsar-io/http/pom.xml
index d899cb53455..a879de890a1 100644
--- a/pulsar-io/http/pom.xml
+++ b/pulsar-io/http/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-io</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-io-http</artifactId>
diff --git a/pulsar-io/influxdb/pom.xml b/pulsar-io/influxdb/pom.xml
index 3494ce4cb7f..e901731380b 100644
--- a/pulsar-io/influxdb/pom.xml
+++ b/pulsar-io/influxdb/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>pulsar-io</artifactId>
         <groupId>org.apache.pulsar</groupId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-io-influxdb</artifactId>
diff --git a/pulsar-io/jdbc/clickhouse/pom.xml b/pulsar-io/jdbc/clickhouse/pom.xml
index 89c17c6042a..42623b2a14a 100644
--- a/pulsar-io/jdbc/clickhouse/pom.xml
+++ b/pulsar-io/jdbc/clickhouse/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <artifactId>pulsar-io-jdbc</artifactId>
     <groupId>org.apache.pulsar</groupId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
 
diff --git a/pulsar-io/jdbc/core/pom.xml b/pulsar-io/jdbc/core/pom.xml
index 7c654a3f2ce..1536b939288 100644
--- a/pulsar-io/jdbc/core/pom.xml
+++ b/pulsar-io/jdbc/core/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <artifactId>pulsar-io-jdbc</artifactId>
     <groupId>org.apache.pulsar</groupId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
 
diff --git a/pulsar-io/jdbc/mariadb/pom.xml b/pulsar-io/jdbc/mariadb/pom.xml
index bfdf84ca2e1..ebf9c4e2916 100644
--- a/pulsar-io/jdbc/mariadb/pom.xml
+++ b/pulsar-io/jdbc/mariadb/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <artifactId>pulsar-io-jdbc</artifactId>
     <groupId>org.apache.pulsar</groupId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
 
diff --git a/pulsar-io/jdbc/openmldb/pom.xml b/pulsar-io/jdbc/openmldb/pom.xml
index 99621398dd5..ce48773952b 100644
--- a/pulsar-io/jdbc/openmldb/pom.xml
+++ b/pulsar-io/jdbc/openmldb/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <artifactId>pulsar-io-jdbc</artifactId>
     <groupId>org.apache.pulsar</groupId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
 
diff --git a/pulsar-io/jdbc/pom.xml b/pulsar-io/jdbc/pom.xml
index 3df0dde4f60..86e4e1cbe90 100644
--- a/pulsar-io/jdbc/pom.xml
+++ b/pulsar-io/jdbc/pom.xml
@@ -33,7 +33,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-jdbc</artifactId>
diff --git a/pulsar-io/jdbc/postgres/pom.xml b/pulsar-io/jdbc/postgres/pom.xml
index 98d823980cd..ea0a0f7c9c8 100644
--- a/pulsar-io/jdbc/postgres/pom.xml
+++ b/pulsar-io/jdbc/postgres/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <artifactId>pulsar-io-jdbc</artifactId>
     <groupId>org.apache.pulsar</groupId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
 
diff --git a/pulsar-io/jdbc/sqlite/pom.xml b/pulsar-io/jdbc/sqlite/pom.xml
index f8c16c621bf..825f8df83fd 100644
--- a/pulsar-io/jdbc/sqlite/pom.xml
+++ b/pulsar-io/jdbc/sqlite/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <artifactId>pulsar-io-jdbc</artifactId>
     <groupId>org.apache.pulsar</groupId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>pulsar-io-jdbc-sqlite</artifactId>
diff --git a/pulsar-io/kafka-connect-adaptor-nar/pom.xml b/pulsar-io/kafka-connect-adaptor-nar/pom.xml
index 5e93501b68e..28d28123ebb 100644
--- a/pulsar-io/kafka-connect-adaptor-nar/pom.xml
+++ b/pulsar-io/kafka-connect-adaptor-nar/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-kafka-connect-adaptor-nar</artifactId>
diff --git a/pulsar-io/kafka-connect-adaptor/pom.xml b/pulsar-io/kafka-connect-adaptor/pom.xml
index 1625c660f87..ba23339e83c 100644
--- a/pulsar-io/kafka-connect-adaptor/pom.xml
+++ b/pulsar-io/kafka-connect-adaptor/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-kafka-connect-adaptor</artifactId>
diff --git a/pulsar-io/kafka/pom.xml b/pulsar-io/kafka/pom.xml
index 33f7918d39e..9b29cbbab7c 100644
--- a/pulsar-io/kafka/pom.xml
+++ b/pulsar-io/kafka/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-kafka</artifactId>
diff --git a/pulsar-io/kinesis/pom.xml b/pulsar-io/kinesis/pom.xml
index b6fa41205c7..7fbd820cc19 100644
--- a/pulsar-io/kinesis/pom.xml
+++ b/pulsar-io/kinesis/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-kinesis</artifactId>
diff --git a/pulsar-io/mongo/pom.xml b/pulsar-io/mongo/pom.xml
index 074ef5991af..11da18eb942 100644
--- a/pulsar-io/mongo/pom.xml
+++ b/pulsar-io/mongo/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
       <artifactId>pulsar-io</artifactId>
-      <version>3.0.10</version>
+      <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-mongo</artifactId>
diff --git a/pulsar-io/netty/pom.xml b/pulsar-io/netty/pom.xml
index cc501325255..5b4f9c89f1c 100644
--- a/pulsar-io/netty/pom.xml
+++ b/pulsar-io/netty/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-io</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-io-netty</artifactId>
diff --git a/pulsar-io/nsq/pom.xml b/pulsar-io/nsq/pom.xml
index 56046e3f3cc..6b4bdfe6213 100644
--- a/pulsar-io/nsq/pom.xml
+++ b/pulsar-io/nsq/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
  
   <artifactId>pulsar-io-nsq</artifactId>
diff --git a/pulsar-io/pom.xml b/pulsar-io/pom.xml
index f0dc27fbf28..be09d0381c1 100644
--- a/pulsar-io/pom.xml
+++ b/pulsar-io/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io</artifactId>
diff --git a/pulsar-io/rabbitmq/pom.xml b/pulsar-io/rabbitmq/pom.xml
index 1a270c87988..635143044da 100644
--- a/pulsar-io/rabbitmq/pom.xml
+++ b/pulsar-io/rabbitmq/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-rabbitmq</artifactId>
diff --git a/pulsar-io/redis/pom.xml b/pulsar-io/redis/pom.xml
index 452f8903e28..b689d5af642 100644
--- a/pulsar-io/redis/pom.xml
+++ b/pulsar-io/redis/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>pulsar-io</artifactId>
         <groupId>org.apache.pulsar</groupId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-io-redis</artifactId>
diff --git a/pulsar-io/solr/pom.xml b/pulsar-io/solr/pom.xml
index 95343bea55d..e4cffd2534a 100644
--- a/pulsar-io/solr/pom.xml
+++ b/pulsar-io/solr/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>pulsar-io</artifactId>
         <groupId>org.apache.pulsar</groupId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <properties>
diff --git a/pulsar-io/twitter/pom.xml b/pulsar-io/twitter/pom.xml
index 636dd1b07e2..bc8127eb980 100644
--- a/pulsar-io/twitter/pom.xml
+++ b/pulsar-io/twitter/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-io</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-io-twitter</artifactId>
diff --git a/pulsar-metadata/pom.xml b/pulsar-metadata/pom.xml
index bdeed6089e7..bbbca16efd0 100644
--- a/pulsar-metadata/pom.xml
+++ b/pulsar-metadata/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/pulsar-package-management/bookkeeper-storage/pom.xml b/pulsar-package-management/bookkeeper-storage/pom.xml
index 670ef1ddcd3..2d9530c041a 100644
--- a/pulsar-package-management/bookkeeper-storage/pom.xml
+++ b/pulsar-package-management/bookkeeper-storage/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>pulsar-package-management</artifactId>
         <groupId>org.apache.pulsar</groupId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
diff --git a/pulsar-package-management/core/pom.xml b/pulsar-package-management/core/pom.xml
index ed157bfa138..f9cdcb8b081 100644
--- a/pulsar-package-management/core/pom.xml
+++ b/pulsar-package-management/core/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>pulsar-package-management</artifactId>
         <groupId>org.apache.pulsar</groupId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
diff --git a/pulsar-package-management/filesystem-storage/pom.xml b/pulsar-package-management/filesystem-storage/pom.xml
index 086c136e675..32bfc0de774 100644
--- a/pulsar-package-management/filesystem-storage/pom.xml
+++ b/pulsar-package-management/filesystem-storage/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>pulsar-package-management</artifactId>
         <groupId>org.apache.pulsar</groupId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
diff --git a/pulsar-package-management/pom.xml b/pulsar-package-management/pom.xml
index 671daa0b7a3..7bd0fde55ec 100644
--- a/pulsar-package-management/pom.xml
+++ b/pulsar-package-management/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>pulsar</artifactId>
         <groupId>org.apache.pulsar</groupId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>
diff --git a/pulsar-proxy/pom.xml b/pulsar-proxy/pom.xml
index a21c6c296b1..291af9de659 100644
--- a/pulsar-proxy/pom.xml
+++ b/pulsar-proxy/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-proxy</artifactId>
diff --git a/pulsar-sql/pom.xml b/pulsar-sql/pom.xml
index 722848b2164..b0c1d747fcb 100644
--- a/pulsar-sql/pom.xml
+++ b/pulsar-sql/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-sql</artifactId>
diff --git a/pulsar-sql/presto-distribution/pom.xml b/pulsar-sql/presto-distribution/pom.xml
index f9cf16808ae..1fa5f8f9f73 100644
--- a/pulsar-sql/presto-distribution/pom.xml
+++ b/pulsar-sql/presto-distribution/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar-sql</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-presto-distribution</artifactId>
diff --git a/pulsar-sql/presto-pulsar-plugin/pom.xml b/pulsar-sql/presto-pulsar-plugin/pom.xml
index f28cce9a35d..7bc0de975cb 100644
--- a/pulsar-sql/presto-pulsar-plugin/pom.xml
+++ b/pulsar-sql/presto-pulsar-plugin/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-sql</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-presto-connector</artifactId>
diff --git a/pulsar-sql/presto-pulsar/pom.xml b/pulsar-sql/presto-pulsar/pom.xml
index 8268f337562..f32df2f438f 100644
--- a/pulsar-sql/presto-pulsar/pom.xml
+++ b/pulsar-sql/presto-pulsar/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-sql</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-presto-connector-original</artifactId>
diff --git a/pulsar-testclient/pom.xml b/pulsar-testclient/pom.xml
index 75d0672c843..3e7cb9b7fad 100644
--- a/pulsar-testclient/pom.xml
+++ b/pulsar-testclient/pom.xml
@@ -25,7 +25,7 @@
 	<parent>
 		<groupId>org.apache.pulsar</groupId>
 		<artifactId>pulsar</artifactId>
-		<version>3.0.10</version>
+		<version>3.0.11-SNAPSHOT</version>
 		<relativePath>..</relativePath>
 	</parent>
 
diff --git a/pulsar-transaction/common/pom.xml b/pulsar-transaction/common/pom.xml
index d3cd72ce0ec..45f8e166bbb 100644
--- a/pulsar-transaction/common/pom.xml
+++ b/pulsar-transaction/common/pom.xml
@@ -27,7 +27,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-transaction-parent</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-transaction-common</artifactId>
diff --git a/pulsar-transaction/coordinator/pom.xml b/pulsar-transaction/coordinator/pom.xml
index 25fceb4b374..1f87fc33ce5 100644
--- a/pulsar-transaction/coordinator/pom.xml
+++ b/pulsar-transaction/coordinator/pom.xml
@@ -27,7 +27,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>pulsar-transaction-parent</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-transaction-coordinator</artifactId>
diff --git a/pulsar-transaction/pom.xml b/pulsar-transaction/pom.xml
index 8c4ee4e8606..40427de2af8 100644
--- a/pulsar-transaction/pom.xml
+++ b/pulsar-transaction/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>pulsar-transaction-parent</artifactId>
diff --git a/pulsar-websocket/pom.xml b/pulsar-websocket/pom.xml
index 0b0c3c1f3bd..830f058a07c 100644
--- a/pulsar-websocket/pom.xml
+++ b/pulsar-websocket/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/structured-event-log/pom.xml b/structured-event-log/pom.xml
index 929b1e7c2a0..dd482936167 100644
--- a/structured-event-log/pom.xml
+++ b/structured-event-log/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/testmocks/pom.xml b/testmocks/pom.xml
index 01e4bbcfb93..ee81ca43317 100644
--- a/testmocks/pom.xml
+++ b/testmocks/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <artifactId>pulsar</artifactId>
     <groupId>org.apache.pulsar</groupId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>testmocks</artifactId>
diff --git a/tests/bc_2_0_0/pom.xml b/tests/bc_2_0_0/pom.xml
index c4ef3ccb76b..4ab97cacc72 100644
--- a/tests/bc_2_0_0/pom.xml
+++ b/tests/bc_2_0_0/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.apache.pulsar.tests</groupId>
         <artifactId>tests-parent</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>bc_2_0_0</artifactId>
diff --git a/tests/bc_2_0_1/pom.xml b/tests/bc_2_0_1/pom.xml
index a53fcfaf752..aa478fe272b 100644
--- a/tests/bc_2_0_1/pom.xml
+++ b/tests/bc_2_0_1/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.apache.pulsar.tests</groupId>
         <artifactId>tests-parent</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>bc_2_0_1</artifactId>
diff --git a/tests/bc_2_6_0/pom.xml b/tests/bc_2_6_0/pom.xml
index 2e9d65d7bf3..2a3e448d980 100644
--- a/tests/bc_2_6_0/pom.xml
+++ b/tests/bc_2_6_0/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.apache.pulsar.tests</groupId>
         <artifactId>tests-parent</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
diff --git a/tests/docker-images/java-test-functions/pom.xml b/tests/docker-images/java-test-functions/pom.xml
index f281682d1e1..0fc5e2c5478 100644
--- a/tests/docker-images/java-test-functions/pom.xml
+++ b/tests/docker-images/java-test-functions/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.pulsar.tests</groupId>
     <artifactId>docker-images</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>java-test-functions</artifactId>
diff --git a/tests/docker-images/java-test-image/pom.xml b/tests/docker-images/java-test-image/pom.xml
index a11d9c1c406..fdc152d7dd8 100644
--- a/tests/docker-images/java-test-image/pom.xml
+++ b/tests/docker-images/java-test-image/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.pulsar.tests</groupId>
     <artifactId>docker-images</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>java-test-image</artifactId>
diff --git a/tests/docker-images/java-test-plugins/pom.xml b/tests/docker-images/java-test-plugins/pom.xml
index cc3a2129998..b966db6495e 100644
--- a/tests/docker-images/java-test-plugins/pom.xml
+++ b/tests/docker-images/java-test-plugins/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.pulsar.tests</groupId>
     <artifactId>docker-images</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>java-test-plugins</artifactId>
diff --git a/tests/docker-images/latest-version-image/pom.xml b/tests/docker-images/latest-version-image/pom.xml
index a8b863f954d..9e15a358a8f 100644
--- a/tests/docker-images/latest-version-image/pom.xml
+++ b/tests/docker-images/latest-version-image/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.pulsar.tests</groupId>
     <artifactId>docker-images</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>latest-version-image</artifactId>
diff --git a/tests/docker-images/pom.xml b/tests/docker-images/pom.xml
index 02ece8d44e5..42b3c950e71 100644
--- a/tests/docker-images/pom.xml
+++ b/tests/docker-images/pom.xml
@@ -27,7 +27,7 @@
   <parent>
     <groupId>org.apache.pulsar.tests</groupId>
     <artifactId>tests-parent</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <artifactId>docker-images</artifactId>
   <name>Apache Pulsar :: Tests :: Docker Images</name>
diff --git a/tests/integration/pom.xml b/tests/integration/pom.xml
index 02eaa9068cf..1c46ca936fb 100644
--- a/tests/integration/pom.xml
+++ b/tests/integration/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar.tests</groupId>
     <artifactId>tests-parent</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
 
   <artifactId>integration</artifactId>
diff --git a/tests/pom.xml b/tests/pom.xml
index 84e27640b92..96290fd07bc 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
   </parent>
   <groupId>org.apache.pulsar.tests</groupId>
   <artifactId>tests-parent</artifactId>
diff --git a/tests/pulsar-client-admin-shade-test/pom.xml b/tests/pulsar-client-admin-shade-test/pom.xml
index f71745f614b..c877ab34985 100644
--- a/tests/pulsar-client-admin-shade-test/pom.xml
+++ b/tests/pulsar-client-admin-shade-test/pom.xml
@@ -26,7 +26,7 @@
     <parent>
         <groupId>org.apache.pulsar.tests</groupId>
         <artifactId>tests-parent</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-client-admin-shade-test</artifactId>
diff --git a/tests/pulsar-client-all-shade-test/pom.xml b/tests/pulsar-client-all-shade-test/pom.xml
index 451db684481..ad7b2ea52ec 100644
--- a/tests/pulsar-client-all-shade-test/pom.xml
+++ b/tests/pulsar-client-all-shade-test/pom.xml
@@ -26,7 +26,7 @@
     <parent>
         <groupId>org.apache.pulsar.tests</groupId>
         <artifactId>tests-parent</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-client-all-shade-test</artifactId>
diff --git a/tests/pulsar-client-shade-test/pom.xml b/tests/pulsar-client-shade-test/pom.xml
index d5a2f5f66aa..b45a206262c 100644
--- a/tests/pulsar-client-shade-test/pom.xml
+++ b/tests/pulsar-client-shade-test/pom.xml
@@ -27,7 +27,7 @@
     <parent>
         <groupId>org.apache.pulsar.tests</groupId>
         <artifactId>tests-parent</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
     </parent>
 
     <artifactId>pulsar-client-shade-test</artifactId>
diff --git a/tiered-storage/file-system/pom.xml b/tiered-storage/file-system/pom.xml
index dd9f853f049..c05b52f0589 100644
--- a/tiered-storage/file-system/pom.xml
+++ b/tiered-storage/file-system/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.apache.pulsar</groupId>
         <artifactId>tiered-storage-parent</artifactId>
-        <version>3.0.10</version>
+        <version>3.0.11-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
diff --git a/tiered-storage/jcloud/pom.xml b/tiered-storage/jcloud/pom.xml
index 8eb3bbf35c5..071b66aec19 100644
--- a/tiered-storage/jcloud/pom.xml
+++ b/tiered-storage/jcloud/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>tiered-storage-parent</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
diff --git a/tiered-storage/pom.xml b/tiered-storage/pom.xml
index 33e1f12ec53..59100f8e4a1 100644
--- a/tiered-storage/pom.xml
+++ b/tiered-storage/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.pulsar</groupId>
     <artifactId>pulsar</artifactId>
-    <version>3.0.10</version>
+    <version>3.0.11-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 


(pulsar) 05/15: [improve] [broker] Make the estimated entry size more accurate (#23931)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit a4c6476842c0bb4c035975a43ba1bb9bd14e67c2
Author: fengyubiao <yu...@streamnative.io>
AuthorDate: Tue Feb 25 12:57:17 2025 +0800

    [improve] [broker] Make the estimated entry size more accurate (#23931)
    
    (cherry picked from commit 35a16768ff095449e228a8aa1774b26a068e67e9)
    (cherry picked from commit d0e95db50b2362aca47507fec4e98a7f4903fe65)
---
 .../bookkeeper/mledger/impl/ManagedCursorImpl.java | 58 +++++++++----
 .../bookkeeper/mledger/impl/ManagedLedgerImpl.java |  2 +
 .../mledger/impl/cache/RangeEntryCacheImpl.java    | 12 +--
 .../impl/InflightReadsLimiterIntegrationTest.java  | 15 ++--
 .../bookkeeper/mledger/impl/ManagedCursorTest.java | 98 ++++++++++++++++++++--
 .../BatchMessageWithBatchIndexLevelTest.java       | 12 +--
 .../pulsar/broker/stats/ConsumerStatsTest.java     | 19 +++--
 7 files changed, 166 insertions(+), 50 deletions(-)

diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
index 0755c284de7..58c95e106ee 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
@@ -24,6 +24,7 @@ import static org.apache.bookkeeper.mledger.ManagedLedgerException.getManagedLed
 import static org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.DEFAULT_LEDGER_DELETE_BACKOFF_TIME_SEC;
 import static org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.DEFAULT_LEDGER_DELETE_RETRIES;
 import static org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.createManagedLedgerException;
+import static org.apache.bookkeeper.mledger.impl.cache.RangeEntryCacheImpl.BOOKKEEPER_READ_OVERHEAD_PER_ENTRY;
 import static org.apache.bookkeeper.mledger.util.Errors.isNoSuchLedgerExistsException;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.MoreObjects;
@@ -3686,26 +3687,51 @@ public class ManagedCursorImpl implements ManagedCursor {
         if (maxSizeBytes == NO_MAX_SIZE_LIMIT) {
             return maxEntries;
         }
+        int maxEntriesBasedOnSize =
+                Long.valueOf(estimateEntryCountBySize(maxSizeBytes, readPosition, ledger)).intValue();
+        return Math.min(maxEntriesBasedOnSize, maxEntries);
+    }
 
-        double avgEntrySize = ledger.getStats().getEntrySizeAverage();
-        if (!Double.isFinite(avgEntrySize)) {
-            // We don't have yet any stats on the topic entries. Let's try to use the cursor avg size stats
-            avgEntrySize = (double) entriesReadSize / (double) entriesReadCount;
-        }
-
-        if (!Double.isFinite(avgEntrySize)) {
-            // If we still don't have any information, it means this is the first time we attempt reading
-            // and there are no writes. Let's start with 1 to avoid any overflow and start the avg stats
-            return 1;
+    static long estimateEntryCountBySize(long bytesSize, PositionImpl readPosition, ManagedLedgerImpl ml) {
+        Position posToRead = readPosition;
+        if (!ml.isValidPosition(readPosition)) {
+            posToRead = ml.getNextValidPosition(readPosition);
         }
+        long result = 0;
+        long remainingBytesSize = bytesSize;
 
-        int maxEntriesBasedOnSize = (int) (maxSizeBytes / avgEntrySize);
-        if (maxEntriesBasedOnSize < 1) {
-            // We need to read at least one entry
-            return 1;
+        while (remainingBytesSize > 0) {
+            // Last ledger.
+            if (posToRead.getLedgerId() == ml.getCurrentLedger().getId()) {
+                if (ml.getCurrentLedgerSize() == 0 ||  ml.getCurrentLedgerEntries() == 0) {
+                    // Only read 1 entry if no entries to read.
+                    return 1;
+                }
+                long avg = Math.max(1, ml.getCurrentLedgerSize() / ml.getCurrentLedgerEntries())
+                        + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY;
+                result += remainingBytesSize / avg;
+                break;
+            }
+            // Skip empty ledger.
+            LedgerInfo ledgerInfo = ml.getLedgersInfo().get(posToRead.getLedgerId());
+            if (ledgerInfo.getSize() == 0 || ledgerInfo.getEntries() == 0) {
+                posToRead = ml.getNextValidPosition(PositionImpl.get(posToRead.getLedgerId(), Long.MAX_VALUE));
+                continue;
+            }
+            // Calculate entries by average of ledgers.
+            long avg = Math.max(1, ledgerInfo.getSize() / ledgerInfo.getEntries()) + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY;
+            long remainEntriesOfLedger = ledgerInfo.getEntries() - posToRead.getEntryId();
+            if (remainEntriesOfLedger * avg >= remainingBytesSize) {
+                result += remainingBytesSize / avg;
+                break;
+            } else {
+                // Calculate for the next ledger.
+                result += remainEntriesOfLedger;
+                remainingBytesSize -= remainEntriesOfLedger * avg;
+                posToRead = ml.getNextValidPosition(PositionImpl.get(posToRead.getLedgerId(), Long.MAX_VALUE));
+            }
         }
-
-        return Math.min(maxEntriesBasedOnSize, maxEntries);
+        return Math.max(result, 1);
     }
 
     @Override
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
index ef5b3b0d33e..93e824157b0 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
@@ -217,6 +217,8 @@ public class ManagedLedgerImpl implements ManagedLedger, CreateCallback {
     private final CallbackMutex offloadMutex = new CallbackMutex();
     private static final CompletableFuture<PositionImpl> NULL_OFFLOAD_PROMISE = CompletableFuture
             .completedFuture(PositionImpl.LATEST);
+    @VisibleForTesting
+    @Getter
     protected volatile LedgerHandle currentLedger;
     protected volatile long currentLedgerEntries = 0;
     protected volatile long currentLedgerSize = 0;
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/RangeEntryCacheImpl.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/RangeEntryCacheImpl.java
index c8d14cebebc..02718561705 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/RangeEntryCacheImpl.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/RangeEntryCacheImpl.java
@@ -302,7 +302,7 @@ public class RangeEntryCacheImpl implements EntryCache {
             doAsyncReadEntriesByPosition(lh, firstPosition, lastPosition, numberOfEntries, shouldCacheEntry,
                     originalCallback, ctx);
         } else {
-            long estimatedEntrySize = getEstimatedEntrySize();
+            long estimatedEntrySize = getEstimatedEntrySize(lh);
             long estimatedReadSize = numberOfEntries * estimatedEntrySize;
             if (log.isDebugEnabled()) {
                 log.debug("Estimated read size: {} bytes for {} entries with {} estimated entry size",
@@ -418,12 +418,12 @@ public class RangeEntryCacheImpl implements EntryCache {
     }
 
     @VisibleForTesting
-    public long getEstimatedEntrySize() {
-        long estimatedEntrySize = getAvgEntrySize();
-        if (estimatedEntrySize == 0) {
-            estimatedEntrySize = DEFAULT_ESTIMATED_ENTRY_SIZE;
+    public long getEstimatedEntrySize(ReadHandle lh) {
+        if (lh.getLength() == 0 || lh.getLastAddConfirmed() < 0) {
+            // No entries stored.
+            return Math.max(getAvgEntrySize(), DEFAULT_ESTIMATED_ENTRY_SIZE) + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY;
         }
-        return estimatedEntrySize + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY;
+        return Math.max(1, lh.getLength() / (lh.getLastAddConfirmed() + 1)) + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY;
     }
 
     private long getAvgEntrySize() {
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/InflightReadsLimiterIntegrationTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/InflightReadsLimiterIntegrationTest.java
index 48f0cf08ddf..6676baf8b55 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/InflightReadsLimiterIntegrationTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/InflightReadsLimiterIntegrationTest.java
@@ -141,10 +141,9 @@ public class InflightReadsLimiterIntegrationTest extends MockedBookKeeperTestCas
         SimpleReadEntriesCallback cb0 = new SimpleReadEntriesCallback();
         entryCache.asyncReadEntry(spyCurrentLedger, 125, 125, true, cb0, ctx);
         cb0.entries.join();
-        Long sizePerEntry1 = entryCache.getEstimatedEntrySize();
-        Assert.assertEquals(sizePerEntry1, 1 + RangeEntryCacheImpl.BOOKKEEPER_READ_OVERHEAD_PER_ENTRY);
+        int sizePerEntry = Long.valueOf(entryCache.getEstimatedEntrySize(ml.currentLedger)).intValue();
         Awaitility.await().untilAsserted(() -> {
-            long remainingBytes =limiter.getRemainingBytes();
+            long remainingBytes = limiter.getRemainingBytes();
             Assert.assertEquals(remainingBytes, totalCapacity);
         });
         log.info("remainingBytes 0: {}", limiter.getRemainingBytes());
@@ -165,7 +164,7 @@ public class InflightReadsLimiterIntegrationTest extends MockedBookKeeperTestCas
             entryCache.asyncReadEntry(spyCurrentLedger, start2, end2, true, cb2, ctx);
         }).start();
 
-        long bytesAcquired1 = calculateBytesSizeBeforeFirstReading(readCount1 + readCount2, 1);
+        long bytesAcquired1 = calculateBytesSizeBeforeFirstReading(readCount1 + readCount2, sizePerEntry);
         long remainingBytesExpected1 = totalCapacity - bytesAcquired1;
         log.info("acquired : {}", bytesAcquired1);
         log.info("remainingBytesExpected 0 : {}", remainingBytesExpected1);
@@ -178,9 +177,7 @@ public class InflightReadsLimiterIntegrationTest extends MockedBookKeeperTestCas
         Thread.sleep(3000);
         readCompleteSignal1.countDown();
         cb1.entries.join();
-        Long sizePerEntry2 = entryCache.getEstimatedEntrySize();
-        Assert.assertEquals(sizePerEntry2, 1 + RangeEntryCacheImpl.BOOKKEEPER_READ_OVERHEAD_PER_ENTRY);
-        long bytesAcquired2 = calculateBytesSizeBeforeFirstReading(readCount2, 1);
+        long bytesAcquired2 = calculateBytesSizeBeforeFirstReading(readCount2, sizePerEntry);
         long remainingBytesExpected2 = totalCapacity - bytesAcquired2;
         log.info("acquired : {}", bytesAcquired2);
         log.info("remainingBytesExpected 1: {}", remainingBytesExpected2);
@@ -191,8 +188,6 @@ public class InflightReadsLimiterIntegrationTest extends MockedBookKeeperTestCas
 
         readCompleteSignal2.countDown();
         cb2.entries.join();
-        Long sizePerEntry3 = entryCache.getEstimatedEntrySize();
-        Assert.assertEquals(sizePerEntry3, 1 + RangeEntryCacheImpl.BOOKKEEPER_READ_OVERHEAD_PER_ENTRY);
         Awaitility.await().untilAsserted(() -> {
             long remainingBytes = limiter.getRemainingBytes();
             log.info("remainingBytes 2: {}", remainingBytes);
@@ -204,7 +199,7 @@ public class InflightReadsLimiterIntegrationTest extends MockedBookKeeperTestCas
     }
 
     private long calculateBytesSizeBeforeFirstReading(int entriesCount, int perEntrySize) {
-        return entriesCount * (perEntrySize + RangeEntryCacheImpl.BOOKKEEPER_READ_OVERHEAD_PER_ENTRY);
+        return entriesCount * perEntrySize;
     }
 
     class SimpleReadEntriesCallback implements AsyncCallbacks.ReadEntriesCallback {
diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
index fe484d62c4e..62c1539648b 100644
--- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
+++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.bookkeeper.mledger.impl;
 
+import static org.apache.bookkeeper.mledger.impl.cache.RangeEntryCacheImpl.BOOKKEEPER_READ_OVERHEAD_PER_ENTRY;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.doAnswer;
@@ -681,13 +682,15 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
         ManagedCursor cursor = ledger.openCursor("c1");
 
         for (int i = 0; i < 100; i++) {
-            ledger.addEntry(new byte[1024]);
+            ledger.addEntry(new byte[(int) (1024)]);
         }
 
-        // First time, since we don't have info, we'll get 1 single entry
-        readAndCheck(cursor, 10, 3 * 1024, 1);
+        // Since https://github.com/apache/pulsar/pull/23931 improved the performance of delivery, the consumer
+        // will get more messages than before(it only receives 1 messages at the first delivery),
+        int avg = (int) (BOOKKEEPER_READ_OVERHEAD_PER_ENTRY + 1024);
+        readAndCheck(cursor, 10, 3 * avg, 3);
         // We should only return 3 entries, based on the max size
-        readAndCheck(cursor, 20, 3 * 1024, 3);
+        readAndCheck(cursor, 20, 3 * avg, 3);
         // If maxSize is < avg, we should get 1 entry
         readAndCheck(cursor, 10, 500, 1);
     }
@@ -3885,13 +3888,15 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
             ledger.addEntry(new byte[1024]);
         }
 
-        // First time, since we don't have info, we'll get 1 single entry
-        List<Entry> entries = c.readEntriesOrWait(10, 3 * 1024);
-        assertEquals(entries.size(), 1);
+        // Since https://github.com/apache/pulsar/pull/23931 improved the performance of delivery, the consumer
+        // will get more messages than before(it only receives 1 messages at the first delivery),
+        int avg = (int) (1024 + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY);
+        List<Entry> entries = c.readEntriesOrWait(10, 3 * avg);
+        assertEquals(entries.size(), 3);
         entries.forEach(Entry::release);
 
         // We should only return 3 entries, based on the max size
-        entries = c.readEntriesOrWait(10, 3 * 1024);
+        entries = c.readEntriesOrWait(10, 3 * avg);
         assertEquals(entries.size(), 3);
         entries.forEach(Entry::release);
 
@@ -4798,5 +4803,82 @@ public class ManagedCursorTest extends MockedBookKeeperTestCase {
         assertEquals(cursor.getReadPosition(), markDeletedPosition.getNext());
     }
 
+    @Test
+    public void testEstimateEntryCountBySize() throws Exception {
+        final String mlName = "ml-" + UUID.randomUUID().toString().replaceAll("-", "");
+        ManagedLedgerImpl ml = (ManagedLedgerImpl) factory.open(mlName);
+        long entryCount0 =
+                ManagedCursorImpl.estimateEntryCountBySize(16, PositionImpl.get(ml.getCurrentLedger().getId(), 0), ml);
+        assertEquals(entryCount0, 1);
+        // Avoid trimming ledgers.
+        ml.openCursor("c1");
+
+        // Build data.
+        for (int i = 0; i < 100; i++) {
+            ml.addEntry(new byte[]{1});
+        }
+        long ledger1 = ml.getCurrentLedger().getId();
+        ml.getCurrentLedger().close();
+        ml.ledgerClosed(ml.getCurrentLedger());
+        for (int i = 0; i < 100; i++) {
+            ml.addEntry(new byte[]{1, 2});
+        }
+        long ledger2 = ml.getCurrentLedger().getId();
+        ml.getCurrentLedger().close();
+        ml.ledgerClosed(ml.getCurrentLedger());
+        for (int i = 0; i < 100; i++) {
+            ml.addEntry(new byte[]{1, 2, 3, 4});
+        }
+        long ledger3 = ml.getCurrentLedger().getId();
+        MLDataFormats.ManagedLedgerInfo.LedgerInfo ledgerInfo1 = ml.getLedgersInfo().get(ledger1);
+        MLDataFormats.ManagedLedgerInfo.LedgerInfo ledgerInfo2 = ml.getLedgersInfo().get(ledger2);
+        long average1 = ledgerInfo1.getSize() / ledgerInfo1.getEntries() + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY;
+        long average2 = ledgerInfo2.getSize() / ledgerInfo2.getEntries() + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY;
+        long average3 = ml.getCurrentLedgerSize() / ml.getCurrentLedgerEntries() + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY;
+        assertEquals(average1, 1 + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY);
+        assertEquals(average2, 2 + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY);
+        assertEquals(average3, 4 + BOOKKEEPER_READ_OVERHEAD_PER_ENTRY);
+
+        // Test: the individual ledgers.
+        long entryCount1 =
+                ManagedCursorImpl.estimateEntryCountBySize(average1 * 16, PositionImpl.get(ledger1, 0), ml);
+        assertEquals(entryCount1, 16);
+        long entryCount2 =
+                ManagedCursorImpl.estimateEntryCountBySize(average2 * 8, PositionImpl.get(ledger2, 0), ml);
+        assertEquals(entryCount2, 8);
+        long entryCount3 =
+                ManagedCursorImpl.estimateEntryCountBySize(average3 * 4, PositionImpl.get(ledger3, 0), ml);
+        assertEquals(entryCount3, 4);
+
+        // Test: across ledgers.
+        long entryCount4 =
+                ManagedCursorImpl.estimateEntryCountBySize((average1 * 100) + (average2 * 8), PositionImpl.get(ledger1, 0), ml);
+        assertEquals(entryCount4, 108);
+        long entryCount5 =
+                ManagedCursorImpl.estimateEntryCountBySize((average2 * 100) + (average3 * 4), PositionImpl.get(ledger2, 0), ml);
+        assertEquals(entryCount5, 104);
+        long entryCount6 =
+                ManagedCursorImpl.estimateEntryCountBySize((average1 * 100) + (average2 * 100) + (average3 * 4), PositionImpl.get(ledger1, 0), ml);
+        assertEquals(entryCount6, 204);
+
+        long entryCount7 =
+                ManagedCursorImpl.estimateEntryCountBySize((average1 * 20) + (average2 * 8), PositionImpl.get(ledger1, 80), ml);
+        assertEquals(entryCount7, 28);
+        long entryCount8 =
+                ManagedCursorImpl.estimateEntryCountBySize((average2 * 20) + (average3 * 4), PositionImpl.get(ledger2, 80), ml);
+        assertEquals(entryCount8, 24);
+        long entryCount9 =
+                ManagedCursorImpl.estimateEntryCountBySize((average1 * 20) + (average2 * 100)  + (average3 * 4), PositionImpl.get(ledger1, 80), ml);
+        assertEquals(entryCount9, 124);
+
+        // Test: read more than entries written.
+        long entryCount10 =
+                ManagedCursorImpl.estimateEntryCountBySize((average1 * 100) + (average2 * 100) + (average3 * 100) + (average3 * 4) , PositionImpl.get(ledger1, 0), ml);
+        assertEquals(entryCount10, 304);
+
+        // cleanup.
+        ml.delete();
+    }
+
     private static final Logger log = LoggerFactory.getLogger(ManagedCursorTest.class);
 }
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageWithBatchIndexLevelTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageWithBatchIndexLevelTest.java
index 52147f74f4a..21a7c179b82 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageWithBatchIndexLevelTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageWithBatchIndexLevelTest.java
@@ -85,7 +85,7 @@ public class BatchMessageWithBatchIndexLevelTest extends BatchMessageTest {
                 .newConsumer()
                 .topic(topicName)
                 .subscriptionName(subscriptionName)
-                .receiverQueueSize(10)
+                .receiverQueueSize(50)
                 .subscriptionType(SubscriptionType.Shared)
                 .enableBatchIndexAcknowledgment(true)
                 .negativeAckRedeliveryDelay(100, TimeUnit.MILLISECONDS)
@@ -114,27 +114,29 @@ public class BatchMessageWithBatchIndexLevelTest extends BatchMessageTest {
         consumer.acknowledge(receive1);
         consumer.acknowledge(receive2);
         Awaitility.await().untilAsserted(() -> {
-            assertEquals(dispatcher.getConsumers().get(0).getUnackedMessages(), 18);
+            // Since https://github.com/apache/pulsar/pull/23931 improved the mechanism of estimate average entry size,
+            // broker will deliver much messages than before. So edit 18 -> 38 here.
+            assertEquals(dispatcher.getConsumers().get(0).getUnackedMessages(), 38);
         });
         Message<byte[]> receive3 = consumer.receive();
         Message<byte[]> receive4 = consumer.receive();
         consumer.acknowledge(receive3);
         consumer.acknowledge(receive4);
         Awaitility.await().untilAsserted(() -> {
-            assertEquals(dispatcher.getConsumers().get(0).getUnackedMessages(), 16);
+            assertEquals(dispatcher.getConsumers().get(0).getUnackedMessages(), 36);
         });
         // Block cmd-flow send until verify finish. see: https://github.com/apache/pulsar/pull/17436.
         consumer.pause();
         Message<byte[]> receive5 = consumer.receive();
         consumer.negativeAcknowledge(receive5);
         Awaitility.await().pollInterval(1, TimeUnit.MILLISECONDS).untilAsserted(() -> {
-            assertEquals(dispatcher.getConsumers().get(0).getUnackedMessages(), 0);
+            assertEquals(dispatcher.getConsumers().get(0).getUnackedMessages(), 20);
         });
         // Unblock cmd-flow.
         consumer.resume();
         consumer.receive();
         Awaitility.await().untilAsserted(() -> {
-            assertEquals(dispatcher.getConsumers().get(0).getUnackedMessages(), 16);
+            assertEquals(dispatcher.getConsumers().get(0).getUnackedMessages(), 36);
         });
     }
 
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/ConsumerStatsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/ConsumerStatsTest.java
index 5aeed40107d..423c4daa291 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/ConsumerStatsTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/ConsumerStatsTest.java
@@ -388,8 +388,13 @@ public class ConsumerStatsTest extends ProducerConsumerBase {
                 .batchingMaxPublishDelay(5, TimeUnit.SECONDS)
                 .batchingMaxBytes(Integer.MAX_VALUE)
                 .create();
-
-        producer.send("first-message");
+        // The first messages deliver: 20 msgs.
+        // Average of "messages per batch" is "1".
+        for (int i = 0; i < 20; i++) {
+            producer.send("first-message");
+        }
+        // The second messages deliver: 20 msgs.
+        // Average of "messages per batch" is "Math.round(1 * 0.9 + 20 * 0.1) = 2.9 ~ 3".
         List<CompletableFuture<MessageId>> futures = new ArrayList<>();
         for (int i = 0; i < 20; i++) {
             futures.add(producer.sendAsync("message"));
@@ -423,6 +428,7 @@ public class ConsumerStatsTest extends ProducerConsumerBase {
         metadataConsumer.put("matchValueReschedule", "producer2");
         @Cleanup
         Consumer<String> consumer = pulsarClient.newConsumer(Schema.STRING).topic(topic).properties(metadataConsumer)
+                .receiverQueueSize(20)
                 .subscriptionName(subName).subscriptionInitialPosition(SubscriptionInitialPosition.Earliest).subscribe();
 
         int counter = 0;
@@ -437,14 +443,17 @@ public class ConsumerStatsTest extends ProducerConsumerBase {
             }
         }
 
-        assertEquals(21, counter);
+        assertEquals(40, counter);
 
         ConsumerStats consumerStats =
                 admin.topics().getStats(topic).getSubscriptions().get(subName).getConsumers().get(0);
 
-        assertEquals(21, consumerStats.getMsgOutCounter());
+        assertEquals(40, consumerStats.getMsgOutCounter());
 
-        // Math.round(1 * 0.9 + 0.1 * (20 / 1))
+        // The first messages deliver: 20 msgs.
+        // Average of "messages per batch" is "1".
+        // The second messages deliver: 20 msgs.
+        // Average of "messages per batch" is "Math.round(1 * 0.9 + 20 * 0.1) = 2.9 ~ 3".
         int avgMessagesPerEntry = consumerStats.getAvgMessagesPerEntry();
         assertEquals(3, avgMessagesPerEntry);
     }


(pulsar) 09/15: [fix][test] Fix flaky test OneWayReplicatorUsingGlobalZKTest.testConfigReplicationStartAt (#24011)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 2d6a03b5bd52b062c829dffe5896840e639f9052
Author: fengyubiao <yu...@streamnative.io>
AuthorDate: Tue Feb 25 14:49:33 2025 +0800

    [fix][test] Fix flaky test OneWayReplicatorUsingGlobalZKTest.testConfigReplicationStartAt (#24011)
    
    (cherry picked from commit 8b196d8abfa1f5e4ac71bea7c08cafa35d04bae2)
    (cherry picked from commit c05e998a5220ff9d0ddc3c3fc36f058bd50b0d27)
---
 .../pulsar/broker/service/OneWayReplicatorUsingGlobalZKTest.java      | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorUsingGlobalZKTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorUsingGlobalZKTest.java
index ef29376368c..f7738c2207b 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorUsingGlobalZKTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorUsingGlobalZKTest.java
@@ -156,6 +156,10 @@ public class OneWayReplicatorUsingGlobalZKTest extends OneWayReplicatorTest {
         p1.close();
 
         admin1.namespaces().setNamespaceReplicationClusters(ns1, new HashSet<>(Arrays.asList(cluster1, cluster2)));
+        Awaitility.await().untilAsserted(() -> {
+            assertTrue(admin2.topics().getList(ns1).contains(topic1));
+        });
+        admin2.topics().createSubscription(topic1, subscription1, MessageId.earliest);
         org.apache.pulsar.client.api.Consumer<String> c1 = client2.newConsumer(Schema.STRING).topic(topic1)
                 .subscriptionName(subscription1).subscribe();
         Message<String> msg2 = c1.receive(2, TimeUnit.SECONDS);


(pulsar) 02/15: [improve][fn] Set default tenant and namespace for ListFunctions cmd (#23881)

Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit a71e39114b51387e74f8a533fcc0b63451fa651b
Author: jiangpengcheng <sc...@gmail.com>
AuthorDate: Fri Jan 24 12:10:59 2025 +0800

    [improve][fn] Set default tenant and namespace for ListFunctions cmd (#23881)
    
    (cherry picked from commit 66d1bb0d734f12d758b0f0e9e3c0b42543508f8d)
    (cherry picked from commit 1abbc3c0cf41ea1bb82c412fc10b475d6df73a00)
---
 .../java/org/apache/pulsar/admin/cli/CmdFunctionsTest.java  | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/CmdFunctionsTest.java b/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/CmdFunctionsTest.java
index 39ede3bb7ae..7eaf0ad9bd6 100644
--- a/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/CmdFunctionsTest.java
+++ b/pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/CmdFunctionsTest.java
@@ -632,6 +632,19 @@ public class CmdFunctionsTest {
         verify(functions, times(1)).getFunctions(eq(TENANT), eq(NAMESPACE));
     }
 
+    @Test
+    public void testListFunctionsWithDefaultValue() throws Exception {
+        cmd.run(new String[] {
+                "list",
+        });
+
+        ListFunctions lister = cmd.getLister();
+        assertEquals("public", lister.getTenant());
+        assertEquals("default", lister.getNamespace());
+
+        verify(functions, times(1)).getFunctions(eq("public"), eq("default"));
+    }
+
     @Test
     public void testStateGetter() throws Exception {
         String key = TEST_NAME + "-key";