You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2024/03/27 19:43:14 UTC
(pulsar) branch branch-2.11 updated: [fix][broker][branch-2.11] Fast fix infinite HTTP call createSubscriptions caused by wrong topicName (#22346)
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-2.11
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-2.11 by this push:
new 2cee88c8f08 [fix][broker][branch-2.11] Fast fix infinite HTTP call createSubscriptions caused by wrong topicName (#22346)
2cee88c8f08 is described below
commit 2cee88c8f08ebd08e6447f18aa44c3af00026974
Author: fengyubiao <yu...@streamnative.io>
AuthorDate: Thu Mar 28 03:43:08 2024 +0800
[fix][broker][branch-2.11] Fast fix infinite HTTP call createSubscriptions caused by wrong topicName (#22346)
---
.../apache/pulsar/broker/admin/impl/PersistentTopicsBase.java | 2 +-
.../api/TopicNameForInfiniteHttpCallGetSubscriptionsTest.java | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)
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 8f6191938ed..2cb8495034b 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
@@ -2234,7 +2234,7 @@ public class PersistentTopicsBase extends AdminResource {
getPartitionedTopicMetadataAsync(topicName, authoritative, allowAutoTopicCreation))
.thenAccept(partitionMetadata -> {
final int numPartitions = partitionMetadata.partitions;
- if (numPartitions > 0) {
+ if (partitionMetadata.partitions > 0 && !isUnexpectedTopicName(partitionMetadata)) {
final CompletableFuture<Void> future = new CompletableFuture<>();
final AtomicInteger count = new AtomicInteger(numPartitions);
final AtomicInteger failureCount = new AtomicInteger(0);
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/TopicNameForInfiniteHttpCallGetSubscriptionsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/TopicNameForInfiniteHttpCallGetSubscriptionsTest.java
index 3b1222f5b55..a295a48b4fd 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/TopicNameForInfiniteHttpCallGetSubscriptionsTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/api/TopicNameForInfiniteHttpCallGetSubscriptionsTest.java
@@ -53,7 +53,7 @@ public class TopicNameForInfiniteHttpCallGetSubscriptionsTest extends ProducerCo
}
@Test
- public void testInfiniteHttpCallGetSubscriptions() throws Exception {
+ public void testInfiniteHttpCallGetOrCreateSubscriptions() throws Exception {
final String randomStr = UUID.randomUUID().toString().replaceAll("-", "");
final String partitionedTopicName = "persistent://my-property/my-ns/tp1_" + randomStr;
final String topic_p0 = partitionedTopicName + TopicName.PARTITIONED_TOPIC_SUFFIX + "0";
@@ -65,6 +65,7 @@ public class TopicNameForInfiniteHttpCallGetSubscriptionsTest extends ProducerCo
// Do test.
ProducerAndConsumerEntry pcEntry = triggerDLQCreated(topic_p0, topicDLQ, subscriptionName);
admin.topics().getSubscriptions(topicDLQ);
+ admin.topics().createSubscription(topicDLQ, "s1", MessageId.earliest);
// cleanup.
pcEntry.consumer.close();
@@ -73,7 +74,7 @@ public class TopicNameForInfiniteHttpCallGetSubscriptionsTest extends ProducerCo
}
@Test
- public void testInfiniteHttpCallGetSubscriptions2() throws Exception {
+ public void testInfiniteHttpCallGetOrCreateSubscriptions2() throws Exception {
final String randomStr = UUID.randomUUID().toString().replaceAll("-", "");
final String topicName = "persistent://my-property/my-ns/tp1_" + randomStr + "-partition-0-abc";
Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
@@ -82,13 +83,14 @@ public class TopicNameForInfiniteHttpCallGetSubscriptionsTest extends ProducerCo
// Do test.
admin.topics().getSubscriptions(topicName);
+ admin.topics().createSubscription(topicName, "s1", MessageId.earliest);
// cleanup.
producer.close();
}
@Test
- public void testInfiniteHttpCallGetSubscriptions3() throws Exception {
+ public void testInfiniteHttpCallGetOrCreateSubscriptions3() throws Exception {
final String randomStr = UUID.randomUUID().toString().replaceAll("-", "");
final String topicName = "persistent://my-property/my-ns/tp1_" + randomStr + "-partition-0";
Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
@@ -97,6 +99,7 @@ public class TopicNameForInfiniteHttpCallGetSubscriptionsTest extends ProducerCo
// Do test.
admin.topics().getSubscriptions(topicName);
+ admin.topics().createSubscription(topicName, "s1", MessageId.earliest);
// cleanup.
producer.close();