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 2025/11/04 21:27:17 UTC
(pulsar) branch branch-4.0 updated (1170afdc367 -> 74931c9e5f2)
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a change to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
from 1170afdc367 [fix][admin] Set local policies overwrites "number of bundles" passed during namespace creation (#24762)
new a3d9c531bc1 [improve][broker] Add tests for using absolute FQDN for advertisedAddress and remove extra dot from brokerId (#24787)
new 645f233878c [fix][monitor] Fix the incorrect metrics name (#21981)
new c2ea6a9afee [fix][broker] Avoid recursive update in ConcurrentHashMap during policy cache cleanup (#24939)
new 74931c9e5f2 [fix][txn] fix concurrent error cause txn stuck in TransactionBufferHandlerImpl#endTxn (#23551)
The 4 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.
Summary of changes:
grafana/dashboards/bookkeeper.json | 8 ++--
.../org/apache/pulsar/broker/PulsarService.java | 14 ++++--
.../SystemTopicBasedTopicPoliciesService.java | 4 +-
.../buffer/impl/TransactionBufferHandlerImpl.java | 4 ++
...tatTest.java => PulsarServiceBrokerIdTest.java} | 29 +++++++-----
.../SystemTopicBasedTopicPoliciesServiceTest.java | 54 ++++++++++++++++++++--
.../ClientTlsAbsoluteAdvertisedAddressTest.java | 34 ++++++--------
7 files changed, 104 insertions(+), 43 deletions(-)
copy pulsar-broker/src/test/java/org/apache/pulsar/broker/{admin/BrokerStatTest.java => PulsarServiceBrokerIdTest.java} (61%)
copy pulsar-functions/proto/src/main/proto/Request.proto => tests/integration/src/test/java/org/apache/pulsar/tests/integration/tls/ClientTlsAbsoluteAdvertisedAddressTest.java (59%)
(pulsar) 02/04: [fix][monitor] Fix the incorrect metrics name (#21981)
Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 645f233878c8de09532ed477f560849169fe327a
Author: crossoverJie <cr...@gmail.com>
AuthorDate: Wed Nov 5 02:45:37 2025 +0800
[fix][monitor] Fix the incorrect metrics name (#21981)
Co-authored-by: Lari Hotari <lh...@users.noreply.github.com>
(cherry picked from commit b7582837fdddde742cb1f6086fdd81320180e0a4)
---
grafana/dashboards/bookkeeper.json | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/grafana/dashboards/bookkeeper.json b/grafana/dashboards/bookkeeper.json
index 0d20797ddbd..79dbbb0848e 100644
--- a/grafana/dashboards/bookkeeper.json
+++ b/grafana/dashboards/bookkeeper.json
@@ -383,7 +383,7 @@
"steppedLine": false,
"targets": [
{
- "expr": "bookkeeper_server_ADD_ENTRY_REQUEST{cluster=~\"$cluster\", kubernetes_pod_name=~\"$bookie\", success=\"true\", quantile=\"0.5\"}",
+ "expr": "bookkeeper_server_ADD_ENTRY{cluster=~\"$cluster\", kubernetes_pod_name=~\"$bookie\", success=\"true\", quantile=\"0.5\"}",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
@@ -461,7 +461,7 @@
"steppedLine": false,
"targets": [
{
- "expr": "bookkeeper_server_READ_ENTRY_REQUEST{cluster=~\"$cluster\", kubernetes_pod_name=~\"$bookie\", success=\"true\", quantile=\"0.5\"}",
+ "expr": "bookkeeper_server_READ_ENTRY{cluster=~\"$cluster\", kubernetes_pod_name=~\"$bookie\", success=\"true\", quantile=\"0.5\"}",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
@@ -551,7 +551,7 @@
"steppedLine": false,
"targets": [
{
- "expr": "bookkeeper_server_ADD_ENTRY_REQUEST{cluster=~\"$cluster\", kubernetes_pod_name=~\"$bookie\", success=\"true\", quantile=\"0.99\"}",
+ "expr": "bookkeeper_server_ADD_ENTRY{cluster=~\"$cluster\", kubernetes_pod_name=~\"$bookie\", success=\"true\", quantile=\"0.99\"}",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
@@ -629,7 +629,7 @@
"steppedLine": false,
"targets": [
{
- "expr": "bookkeeper_server_READ_ENTRY_REQUEST{cluster=~\"$cluster\", kubernetes_pod_name=~\"$bookie\", success=\"true\", quantile=\"0.99\"}",
+ "expr": "bookkeeper_server_READ_ENTRY{cluster=~\"$cluster\", kubernetes_pod_name=~\"$bookie\", success=\"true\", quantile=\"0.99\"}",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
(pulsar) 03/04: [fix][broker] Avoid recursive update in ConcurrentHashMap during policy cache cleanup (#24939)
Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit c2ea6a9afeee9f436d9c44564b5f9e8d343e334c
Author: Cong Zhao <zh...@apache.org>
AuthorDate: Wed Nov 5 02:46:05 2025 +0800
[fix][broker] Avoid recursive update in ConcurrentHashMap during policy cache cleanup (#24939)
(cherry picked from commit 344905f136af9dbc6b132d12b4a7050a8964055d)
---
.../SystemTopicBasedTopicPoliciesService.java | 4 +-
.../SystemTopicBasedTopicPoliciesServiceTest.java | 54 ++++++++++++++++++++--
2 files changed, 53 insertions(+), 5 deletions(-)
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
index 880498209a6..c745d591a4e 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
@@ -589,7 +589,7 @@ public class SystemTopicBasedTopicPoliciesService implements TopicPoliciesServic
// Read policies in background
.thenAccept(__ -> readMorePoliciesAsync(reader));
});
- initFuture.exceptionally(ex -> {
+ initFuture.exceptionallyAsync(ex -> {
try {
if (closed.get()) {
return null;
@@ -603,7 +603,7 @@ public class SystemTopicBasedTopicPoliciesService implements TopicPoliciesServic
namespace, cleanupEx);
}
return null;
- });
+ }, pulsarService.getExecutor());
// let caller know we've got an exception.
return initFuture;
}).thenApply(__ -> true);
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesServiceTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesServiceTest.java
index 8149b7a9435..4326f83d763 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesServiceTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesServiceTest.java
@@ -18,13 +18,16 @@
*/
package org.apache.pulsar.broker.service;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.spy;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNull;
+import java.time.Duration;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@@ -45,7 +48,6 @@ import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.common.policies.data.ClusterData;
import org.apache.pulsar.common.policies.data.TenantInfoImpl;
import org.apache.pulsar.common.policies.data.TopicPolicies;
-import org.assertj.core.api.Assertions;
import org.awaitility.Awaitility;
import org.mockito.Mockito;
import org.testng.Assert;
@@ -319,12 +321,12 @@ public class SystemTopicBasedTopicPoliciesServiceTest extends MockedPulsarServic
spy(new ConcurrentHashMap<TopicName, TopicPolicies>());
FieldUtils.writeDeclaredField(topicPoliciesService, "policiesCache", spyPoliciesCache, true);
- Awaitility.await().untilAsserted(() -> Assertions.assertThat(
+ Awaitility.await().untilAsserted(() -> assertThat(
TopicPolicyTestUtils.getTopicPolicies(topicPoliciesService, TopicName.get(topic))).isNull());
admin.topicPolicies().setMaxConsumersPerSubscription(topic, 1);
Awaitility.await().untilAsserted(() -> {
- Assertions.assertThat(TopicPolicyTestUtils.getTopicPolicies(pulsar.getTopicPoliciesService(),
+ assertThat(TopicPolicyTestUtils.getTopicPolicies(pulsar.getTopicPoliciesService(),
TopicName.get(topic))).isNotNull();
});
@@ -421,4 +423,50 @@ public class SystemTopicBasedTopicPoliciesServiceTest extends MockedPulsarServic
service.prepareInitPoliciesCacheAsync(namespaceName).get();
admin.namespaces().deleteNamespace(NAMESPACE5);
}
+
+ @Test
+ public void testCreateNamespaceEventsSystemTopicFactoryException() throws Exception {
+ final String namespace = "system-topic/namespace-6";
+
+ admin.namespaces().createNamespace(namespace);
+
+ TopicName topicName = TopicName.get("persistent", NamespaceName.get(namespace), "topic-1");
+
+ SystemTopicBasedTopicPoliciesService service =
+ Mockito.spy((SystemTopicBasedTopicPoliciesService) pulsar.getTopicPoliciesService());
+
+ // inject exception when create NamespaceEventsSystemTopicFactory
+ Mockito.doThrow(new RuntimeException("test exception"))
+ .doCallRealMethod()
+ .when(service)
+ .getNamespaceEventsSystemTopicFactory();
+
+ CompletableFuture<Optional<TopicPolicies>> topicPoliciesFuture;
+ Optional<TopicPolicies> topicPoliciesOptional;
+ try {
+ topicPoliciesFuture =
+ service.getTopicPoliciesAsync(topicName, TopicPoliciesService.GetType.LOCAL_ONLY);
+ topicPoliciesOptional = topicPoliciesFuture.join();
+ Assert.fail();
+ } catch (Exception e) {
+ Assert.assertTrue(e.getCause().getMessage().contains("test exception"));
+ }
+
+ Awaitility.await().untilAsserted(() -> {
+ assertThat(service.updateTopicPoliciesAsync(topicName, false, false, topicPolicies ->
+ topicPolicies.setMaxConsumerPerTopic(10)))
+ .succeedsWithin(Duration.ofSeconds(2));
+ });
+
+ topicPoliciesFuture =
+ service.getTopicPoliciesAsync(topicName, TopicPoliciesService.GetType.LOCAL_ONLY);
+ topicPoliciesOptional = topicPoliciesFuture.join();
+
+ Assert.assertNotNull(topicPoliciesOptional);
+ Assert.assertTrue(topicPoliciesOptional.isPresent());
+
+ TopicPolicies topicPolicies = topicPoliciesOptional.get();
+ Assert.assertNotNull(topicPolicies);
+ Assert.assertEquals(topicPolicies.getMaxConsumerPerTopic(), 10);
+ }
}
(pulsar) 01/04: [improve][broker] Add tests for using absolute FQDN for advertisedAddress and remove extra dot from brokerId (#24787)
Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit a3d9c531bc174692481997f96e9239f37a562f18
Author: Lari Hotari <lh...@users.noreply.github.com>
AuthorDate: Tue Nov 4 20:33:27 2025 +0200
[improve][broker] Add tests for using absolute FQDN for advertisedAddress and remove extra dot from brokerId (#24787)
(cherry picked from commit a1ed5c4a26029a6c6d6cb455ee653f133d651ce7)
---
.../org/apache/pulsar/broker/PulsarService.java | 14 ++++--
.../pulsar/broker/PulsarServiceBrokerIdTest.java | 57 ++++++++++++++++++++++
.../ClientTlsAbsoluteAdvertisedAddressTest.java | 33 +++++++++++++
3 files changed, 101 insertions(+), 3 deletions(-)
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
index 5fd63502f8e..56949873621 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
@@ -960,9 +960,7 @@ public class PulsarService implements AutoCloseable, ShutdownService {
// the broker id is used in the load manager to identify the broker
// it should not be used for making connections to the broker
- this.brokerId =
- String.format("%s:%s", advertisedAddress, config.getWebServicePort()
- .or(config::getWebServicePortTls).orElseThrow());
+ this.brokerId = createBrokerId();
if (this.compactionServiceFactory == null) {
this.compactionServiceFactory = loadCompactionServiceFactory();
@@ -1092,6 +1090,16 @@ public class PulsarService implements AutoCloseable, ShutdownService {
}
}
+ private String createBrokerId() {
+ // Remove any trailing dot from the absolute FQDN in the broker id to prevent it from impacting
+ // broker entries in the metadata store when making the advertised address absolute
+ String brokerIdHostPart = advertisedAddress.replaceFirst("\\.$", "");
+ // Although broker id contains a hostname and port, it is not meant to be used for connecting to the broker,
+ // It is simply a unique identifier for the broker.
+ return String.format("%s:%s", brokerIdHostPart, config.getWebServicePort()
+ .or(config::getWebServicePortTls).orElseThrow());
+ }
+
public void runWhenReadyForIncomingRequests(Runnable runnable) {
// Here we don't call the thenRun() methods because CompletableFuture maintains a stack for pending callbacks,
// not a queue. Once the future is complete, the pending callbacks will be executed in reverse order of
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/PulsarServiceBrokerIdTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/PulsarServiceBrokerIdTest.java
new file mode 100644
index 00000000000..d3304671eac
--- /dev/null
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/PulsarServiceBrokerIdTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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;
+
+import java.net.InetAddress;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+@Slf4j
+public class PulsarServiceBrokerIdTest extends MockedPulsarServiceBaseTest {
+ private String hostAddress;
+
+ @BeforeMethod
+ @Override
+ protected void setup() throws Exception {
+ super.internalSetup();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ @Override
+ protected void cleanup() throws Exception {
+ super.internalCleanup();
+ }
+
+ @Override
+ protected void doInitConf() throws Exception {
+ super.doInitConf();
+ hostAddress = InetAddress.getLocalHost().getCanonicalHostName();
+ // make it an absolute FQDN by adding a trailing dot
+ conf.setAdvertisedAddress(hostAddress + ".");
+ }
+
+ @Test
+ public void testBrokerIdDoesntContainTrailingDot() throws Exception {
+ Assert.assertEquals(pulsar.getBrokerId(), hostAddress + ":" + conf.getWebServicePort().get());
+ }
+}
diff --git a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/tls/ClientTlsAbsoluteAdvertisedAddressTest.java b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/tls/ClientTlsAbsoluteAdvertisedAddressTest.java
new file mode 100644
index 00000000000..9f87a1c9ce7
--- /dev/null
+++ b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/tls/ClientTlsAbsoluteAdvertisedAddressTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.tests.integration.tls;
+
+/**
+ * Test that the client can connect to a broker using TLS with an absolute advertised address.
+ */
+public class ClientTlsAbsoluteAdvertisedAddressTest extends ClientTlsTest {
+ @Override
+ protected void beforeStartCluster() throws Exception {
+ super.beforeStartCluster();
+ getPulsarCluster().getBrokers().forEach(brokerContainer -> {
+ // make the advertised address absolute by adding a dot at the end
+ brokerContainer.withEnv("advertisedAddress", brokerContainer.getHostName() + ".");
+ });
+ }
+}
\ No newline at end of file
(pulsar) 04/04: [fix][txn] fix concurrent error cause txn stuck in TransactionBufferHandlerImpl#endTxn (#23551)
Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 74931c9e5f2f4384ed3b048101051dd8e5ea4a9a
Author: ken <16...@qq.com>
AuthorDate: Wed Nov 5 04:17:14 2025 +0800
[fix][txn] fix concurrent error cause txn stuck in TransactionBufferHandlerImpl#endTxn (#23551)
Co-authored-by: fanjianye <fa...@bigo.sg>
(cherry picked from commit c4f125cfa292a8d61e0d037fa2d0fa1e89308b29)
---
.../broker/transaction/buffer/impl/TransactionBufferHandlerImpl.java | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TransactionBufferHandlerImpl.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TransactionBufferHandlerImpl.java
index 34ee28693b4..181ed3acb1e 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TransactionBufferHandlerImpl.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TransactionBufferHandlerImpl.java
@@ -128,6 +128,9 @@ public class TransactionBufferHandlerImpl implements TransactionBufferHandler {
}
} else {
pendingRequests.add(op);
+ if (currentPermits != REQUEST_CREDITS_UPDATER.get(this)) {
+ checkPendingRequests();
+ }
return false;
}
}
@@ -251,6 +254,7 @@ public class TransactionBufferHandlerImpl implements TransactionBufferHandler {
invalid.recycle();
}
endTxn(polled);
+ break;
} else {
REQUEST_CREDITS_UPDATER.incrementAndGet(this);
}