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 2026/04/21 16:14:53 UTC

(pulsar) branch branch-3.0 updated (b7750140a7c -> 87783896c87)

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

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


    from b7750140a7c [fix][build][branch-3.0] Fix trino license
     new 069d1a489fd [improve][common] Optimize TopicName.get() to reduce lock contention on cache lookup (#25367)
     new fbbfe872556 [improve][broker] Improve the performance of TopicName constructor (#24463)
     new 87783896c87 [fix][sec] Upgrade log4j to 2.25.4 to address CVE-2026-34477, CVE-2026-34478, CVE-2026-34480, CVE-2026-34481 (#25521)

The 3 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:
 buildtools/pom.xml                                 |   2 +-
 distribution/server/src/assemble/LICENSE.bin.txt   |   8 +-
 distribution/shell/src/assemble/LICENSE.bin.txt    |   8 +-
 .../broker/naming/TopicNameGetBenchmark.java       |  88 +++++++++++++++++
 .../apache/pulsar/broker/naming}/package-info.java |   5 +-
 pom.xml                                            |   2 +-
 .../org/apache/pulsar/common/naming/TopicName.java | 104 ++++++++++-----------
 pulsar-sql/presto-distribution/LICENSE             |   6 +-
 8 files changed, 155 insertions(+), 68 deletions(-)
 create mode 100644 microbench/src/main/java/org/apache/pulsar/broker/naming/TopicNameGetBenchmark.java
 copy {pulsar-client-auth-sasl/src/main/java/org/apache/pulsar/client/impl/auth => microbench/src/main/java/org/apache/pulsar/broker/naming}/package-info.java (83%)


(pulsar) 03/03: [fix][sec] Upgrade log4j to 2.25.4 to address CVE-2026-34477, CVE-2026-34478, CVE-2026-34480, CVE-2026-34481 (#25521)

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

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

commit 87783896c878ef6b11cc58277b202116502e3941
Author: Matteo Merli <mm...@apache.org>
AuthorDate: Wed Apr 15 09:18:24 2026 -0700

    [fix][sec] Upgrade log4j to 2.25.4 to address CVE-2026-34477, CVE-2026-34478, CVE-2026-34480, CVE-2026-34481 (#25521)
    
    Upgrades org.apache.logging.log4j:* from 2.25.3 to 2.25.4 to fix:
    - CVE-2026-34477: verifyHostName attribute silently ignored in TLS configuration
    - CVE-2026-34478: log injection in Rfc5424Layout due to silent configuration incompatibility
    - CVE-2026-34480: XmlLayout fails to sanitize characters forbidden by XML 1.0
    - CVE-2026-34481: JsonTemplateLayout produces invalid JSON for non-finite floats
    
    (cherry picked from commit dfb06f183c312b849fce42d729c6b36181239490)
---
 buildtools/pom.xml                               | 2 +-
 distribution/server/src/assemble/LICENSE.bin.txt | 8 ++++----
 distribution/shell/src/assemble/LICENSE.bin.txt  | 8 ++++----
 pom.xml                                          | 2 +-
 pulsar-sql/presto-distribution/LICENSE           | 6 +++---
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/buildtools/pom.xml b/buildtools/pom.xml
index 29719a3262f..801cc60ce32 100644
--- a/buildtools/pom.xml
+++ b/buildtools/pom.xml
@@ -48,7 +48,7 @@
     <maven.compiler.target>1.8</maven.compiler.target>
     <maven.compiler.release>8</maven.compiler.release>
     <surefire.version>3.1.0</surefire.version>
-    <log4j2.version>2.25.3</log4j2.version>
+    <log4j2.version>2.25.4</log4j2.version>
     <slf4j.version>1.7.32</slf4j.version>
     <testng.version>7.7.1</testng.version>
     <commons-lang3.version>3.18.0</commons-lang3.version>
diff --git a/distribution/server/src/assemble/LICENSE.bin.txt b/distribution/server/src/assemble/LICENSE.bin.txt
index 1d86377828f..9b19de453ac 100644
--- a/distribution/server/src/assemble/LICENSE.bin.txt
+++ b/distribution/server/src/assemble/LICENSE.bin.txt
@@ -337,10 +337,10 @@ The Apache Software License, Version 2.0
     - jakarta.validation-jakarta.validation-api-2.0.2.jar
     - javax.validation-validation-api-1.1.0.Final.jar
  * Log4J
-    - org.apache.logging.log4j-log4j-api-2.25.3.jar
-    - org.apache.logging.log4j-log4j-core-2.25.3.jar
-    - org.apache.logging.log4j-log4j-slf4j-impl-2.25.3.jar
-    - org.apache.logging.log4j-log4j-web-2.25.3.jar
+    - org.apache.logging.log4j-log4j-api-2.25.4.jar
+    - org.apache.logging.log4j-log4j-core-2.25.4.jar
+    - org.apache.logging.log4j-log4j-slf4j-impl-2.25.4.jar
+    - org.apache.logging.log4j-log4j-web-2.25.4.jar
  * Java Native Access JNA
     - net.java.dev.jna-jna-jpms-5.12.1.jar
     - net.java.dev.jna-jna-platform-jpms-5.12.1.jar
diff --git a/distribution/shell/src/assemble/LICENSE.bin.txt b/distribution/shell/src/assemble/LICENSE.bin.txt
index c5ae5aca399..0c326037289 100644
--- a/distribution/shell/src/assemble/LICENSE.bin.txt
+++ b/distribution/shell/src/assemble/LICENSE.bin.txt
@@ -384,10 +384,10 @@ The Apache Software License, Version 2.0
     - simpleclient_tracer_otel-0.16.0.jar
     - simpleclient_tracer_otel_agent-0.16.0.jar
  * Log4J
-    - log4j-api-2.25.3.jar
-    - log4j-core-2.25.3.jar
-    - log4j-slf4j-impl-2.25.3.jar
-    - log4j-web-2.25.3.jar
+    - log4j-api-2.25.4.jar
+    - log4j-core-2.25.4.jar
+    - log4j-slf4j-impl-2.25.4.jar
+    - log4j-web-2.25.4.jar
 
  * BookKeeper
     - bookkeeper-common-allocator-4.16.7.jar
diff --git a/pom.xml b/pom.xml
index 539dd46acf4..4cce4228d55 100644
--- a/pom.xml
+++ b/pom.xml
@@ -152,7 +152,7 @@ flexible messaging model and an intuitive client API.</description>
     <rocksdb.version>7.9.2</rocksdb.version>
     <slf4j.version>1.7.32</slf4j.version>
     <commons.collections4.version>4.4</commons.collections4.version>
-    <log4j2.version>2.25.3</log4j2.version>
+    <log4j2.version>2.25.4</log4j2.version>
     <!-- bouncycastle dependencies aren't necessarily aligned -->
     <bouncycastle.bcprov-jdk18on.version>1.78.1</bouncycastle.bcprov-jdk18on.version>
     <bouncycastle.bcpkix-jdk18on.version>1.81</bouncycastle.bcpkix-jdk18on.version>
diff --git a/pulsar-sql/presto-distribution/LICENSE b/pulsar-sql/presto-distribution/LICENSE
index 7be45480854..c063fb4fabb 100644
--- a/pulsar-sql/presto-distribution/LICENSE
+++ b/pulsar-sql/presto-distribution/LICENSE
@@ -347,9 +347,9 @@ The Apache Software License, Version 2.0
     - leveldb-0.12.jar
     - leveldb-api-0.12.jar
   * Log4j
-    - log4j-api-2.25.3.jar
-    - log4j-core-2.25.3.jar
-    - log4j-slf4j-impl-2.25.3.jar
+    - log4j-api-2.25.4.jar
+    - log4j-core-2.25.4.jar
+    - log4j-slf4j-impl-2.25.4.jar
   * Log4j implemented over SLF4J
     - log4j-over-slf4j-1.7.32.jar
   * Lucene Common Analyzers


(pulsar) 01/03: [improve][common] Optimize TopicName.get() to reduce lock contention on cache lookup (#25367)

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

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

commit 069d1a489fd9e2827858f5f020ed7ac6a7fff625
Author: Xiangying Meng <55...@users.noreply.github.com>
AuthorDate: Tue Apr 21 16:56:01 2026 +0800

    [improve][common] Optimize TopicName.get() to reduce lock contention on cache lookup (#25367)
    
    ### Motivation
    
    `TopicName.get()` previously used `ConcurrentHashMap.computeIfAbsent()` to populate the topic-name cache. Although `computeIfAbsent` is atomic, it holds the internal bin-lock for the entire duration of the mapping function, which includes the non-trivial `TopicName` construction (string splitting, validation, etc.).
    
    Under high-concurrency workloads where many threads simultaneously encounter the same uncached topic name, this causes unnecessary lock contention and can degrade throughput.
    
    ### Modifications
    
    Replace `computeIfAbsent` with an explicit two-step pattern:
    
    1. **Fast path**: call `cache.get(topic)` first — a single volatile read with no locking — and return immediately on a cache hit (steady-state case).
    2. **Slow path** (cache miss): construct `TopicName` *outside* the lock, then use `cache.put()` to insert.
    
    (cherry picked from commit 8c4e83d2374a6431953684bfadbf5abc301dd26f)
---
 .../broker/naming/TopicNameGetBenchmark.java       | 88 ++++++++++++++++++++++
 .../apache/pulsar/broker/naming/package-info.java  | 23 ++++++
 .../org/apache/pulsar/common/naming/TopicName.java |  7 +-
 3 files changed, 117 insertions(+), 1 deletion(-)

diff --git a/microbench/src/main/java/org/apache/pulsar/broker/naming/TopicNameGetBenchmark.java b/microbench/src/main/java/org/apache/pulsar/broker/naming/TopicNameGetBenchmark.java
new file mode 100644
index 00000000000..74188e16d3a
--- /dev/null
+++ b/microbench/src/main/java/org/apache/pulsar/broker/naming/TopicNameGetBenchmark.java
@@ -0,0 +1,88 @@
+/*
+ * 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.naming;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.pulsar.common.naming.TopicName;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OperationsPerInvocation;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Threads;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.infra.Blackhole;
+
+/**
+ * JMH benchmark for {@link TopicName#get(String)} cold-start (cache-miss) performance
+ * under 50-thread contention.
+ *
+ * <p>Uses {@code Mode.SingleShotTime} with {@code @Fork(10)} to measure
+ * the total time of a fixed batch of cold-start calls. No cache clearing is
+ * needed — each fork is a fresh JVM with an empty cache, and the batch size
+ * is bounded to avoid OOM.
+ *
+ * <p>Run with:
+ * <pre>
+ *   ./gradlew :microbench:shadowJar
+ *   java -jar microbench/build/libs/microbench-*-benchmarks.jar TopicNameGetBenchmark
+ * </pre>
+ */
+@Fork(10)
+@BenchmarkMode(Mode.SingleShotTime)
+@OutputTimeUnit(TimeUnit.MICROSECONDS)
+@Warmup(iterations = 2)
+@Measurement(iterations = 5)
+@Threads(50)
+@State(Scope.Thread)
+public class TopicNameGetBenchmark {
+
+    /**
+     * Each thread processes 10,000 unique topics per invocation.
+     * 50 threads × 10,000 = 500,000 total entries per invocation — well within memory.
+     */
+    private static final int BATCH_SIZE = 10_000;
+    private static final AtomicInteger COUNTER = new AtomicInteger();
+
+    private String[] topics;
+
+    @Setup(Level.Invocation)
+    public void prepare() {
+        int base = COUNTER.getAndAdd(BATCH_SIZE);
+        topics = new String[BATCH_SIZE];
+        for (int i = 0; i < BATCH_SIZE; i++) {
+            topics[i] = "persistent://public/default/topic-" + (base + i);
+        }
+    }
+
+    @Benchmark
+    @OperationsPerInvocation(BATCH_SIZE)
+    public void coldStartGet(Blackhole bh) {
+        for (int i = 0; i < BATCH_SIZE; i++) {
+            bh.consume(TopicName.get(topics[i]));
+        }
+    }
+}
diff --git a/microbench/src/main/java/org/apache/pulsar/broker/naming/package-info.java b/microbench/src/main/java/org/apache/pulsar/broker/naming/package-info.java
new file mode 100644
index 00000000000..f655bf0490d
--- /dev/null
+++ b/microbench/src/main/java/org/apache/pulsar/broker/naming/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+/**
+ * Benchmarks for {@link org.apache.pulsar.common.naming.TopicName#get(String)} cold-start (cache-miss) performance
+ */
+package org.apache.pulsar.broker.naming;
\ No newline at end of file
diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java b/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
index 30c7da14459..a14dd228e75 100644
--- a/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
+++ b/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
@@ -79,11 +79,16 @@ public class TopicName implements ServiceUnitId {
     }
 
     public static TopicName get(String topic) {
+        // Fast path: already cached — single volatile read, no lock.
         TopicName tp = cache.get(topic);
         if (tp != null) {
             return tp;
         }
-        return cache.computeIfAbsent(topic, k -> new TopicName(k));
+        // Use get()+put() instead of computeIfAbsent() to keep construction outside the bin-lock.
+        // Duplicate instances from racing threads are safe to discard since TopicName is immutable.
+        TopicName newTp = new TopicName(topic);
+        TopicName existing = cache.put(topic, newTp);
+        return existing != null ? existing : newTp;
     }
 
     public static TopicName getPartitionedTopicName(String topic) {


(pulsar) 02/03: [improve][broker] Improve the performance of TopicName constructor (#24463)

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

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

commit fbbfe8725566a11e20fc23e9219cb3fdbd6cc610
Author: Yunze Xu <xy...@163.com>
AuthorDate: Tue Apr 21 19:08:11 2026 +0800

    [improve][broker] Improve the performance of TopicName constructor (#24463)
    
    (cherry picked from commit 3130a93b1abc053fc5e5c9687df044a6091d0a3c)
---
 .../org/apache/pulsar/common/naming/TopicName.java | 97 ++++++++++------------
 1 file changed, 45 insertions(+), 52 deletions(-)

diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java b/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
index a14dd228e75..7c475cd0969 100644
--- a/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
+++ b/pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
@@ -121,59 +121,54 @@ public class TopicName implements ServiceUnitId {
         try {
             // The topic name can be in two different forms, one is fully qualified topic name,
             // the other one is short topic name
-            if (!completeTopicName.contains("://")) {
+            int index = completeTopicName.indexOf("://");
+            if (index < 0) {
                 // The short topic name can be:
                 // - <topic>
                 // - <property>/<namespace>/<topic>
-                String[] parts = StringUtils.split(completeTopicName, '/');
-                if (parts.length == 3) {
-                    completeTopicName = TopicDomain.persistent.name() + "://" + completeTopicName;
-                } else if (parts.length == 1) {
-                    completeTopicName = TopicDomain.persistent.name() + "://"
-                        + PUBLIC_TENANT + "/" + DEFAULT_NAMESPACE + "/" + parts[0];
+                List<String> parts = splitBySlash(completeTopicName, 0);
+                this.domain = TopicDomain.persistent;
+                this.cluster = null;
+                if (parts.size() == 3) {
+                    this.tenant = parts.get(0);
+                    this.namespacePortion = parts.get(1);
+                    this.localName = parts.get(2);
+                } else if (parts.size() == 1) {
+                    this.tenant = PUBLIC_TENANT;
+                    this.namespacePortion = DEFAULT_NAMESPACE;
+                    this.localName = parts.get(0);
                 } else {
                     throw new IllegalArgumentException(
                         "Invalid short topic name '" + completeTopicName + "', it should be in the format of "
                         + "<tenant>/<namespace>/<topic> or <topic>");
                 }
-            }
-
-            // The fully qualified topic name can be in two different forms:
-            // new:    persistent://tenant/namespace/topic
-            // legacy: persistent://tenant/cluster/namespace/topic
-
-            List<String> parts = Splitter.on("://").limit(2).splitToList(completeTopicName);
-            this.domain = TopicDomain.getEnum(parts.get(0));
-
-            String rest = parts.get(1);
-
-            // The rest of the name can be in different forms:
-            // new:    tenant/namespace/<localName>
-            // legacy: tenant/cluster/namespace/<localName>
-            // Examples of localName:
-            // 1. some, name, xyz
-            // 2. xyz-123, feeder-2
-
-
-            parts = Splitter.on("/").limit(4).splitToList(rest);
-            if (parts.size() == 3) {
-                // New topic name without cluster name
-                this.tenant = parts.get(0);
-                this.cluster = null;
-                this.namespacePortion = parts.get(1);
-                this.localName = parts.get(2);
-                this.partitionIndex = getPartitionIndex(completeTopicName);
-                this.namespaceName = NamespaceName.get(tenant, namespacePortion);
-            } else if (parts.size() == 4) {
-                // Legacy topic name that includes cluster name
-                this.tenant = parts.get(0);
-                this.cluster = parts.get(1);
-                this.namespacePortion = parts.get(2);
-                this.localName = parts.get(3);
-                this.partitionIndex = getPartitionIndex(completeTopicName);
-                this.namespaceName = NamespaceName.get(tenant, cluster, namespacePortion);
+                this.completeTopicName = domain.name() + "://" + tenant + "/" + namespacePortion + "/" + localName;
             } else {
-                throw new IllegalArgumentException("Invalid topic name: " + completeTopicName);
+                // The fully qualified topic name can be in two different forms:
+                // new:    persistent://tenant/namespace/topic
+                // legacy: persistent://tenant/cluster/namespace/topic
+                //
+                // Examples of localName:
+                // 1. some, name, xyz
+                // 2. xyz-123, feeder-2
+                List<String> parts = splitBySlash(completeTopicName.substring(index + "://".length()), 4);
+                if (parts.size() == 3) {
+                    // New topic name without cluster name
+                    this.cluster = null;
+                    this.tenant = parts.get(0);
+                    this.namespacePortion = parts.get(1);
+                    this.localName = parts.get(2);
+                } else if (parts.size() == 4) {
+                    // Legacy topic name that includes cluster name
+                    this.tenant = parts.get(0);
+                    this.cluster = parts.get(1);
+                    this.namespacePortion = parts.get(2);
+                    this.localName = parts.get(3);
+                } else {
+                    throw new IllegalArgumentException("Invalid topic name " + completeTopicName);
+                }
+                this.completeTopicName = completeTopicName;
+                this.domain = TopicDomain.getEnum(completeTopicName.substring(0, index));
             }
 
             if (StringUtils.isBlank(localName)) {
@@ -181,17 +176,15 @@ public class TopicName implements ServiceUnitId {
                         + " be blank.", completeTopicName));
             }
 
+            this.partitionIndex = getPartitionIndex(localName);
+            if (cluster == null) {
+                this.namespaceName = NamespaceName.get(tenant, namespacePortion);
+            } else {
+                this.namespaceName = NamespaceName.get(tenant, cluster, namespacePortion);
+            }
         } catch (NullPointerException e) {
             throw new IllegalArgumentException("Invalid topic name: " + completeTopicName, e);
         }
-        if (isV2()) {
-            this.completeTopicName = String.format("%s://%s/%s/%s",
-                                                   domain, tenant, namespacePortion, localName);
-        } else {
-            this.completeTopicName = String.format("%s://%s/%s/%s/%s",
-                                                   domain, tenant, cluster,
-                                                   namespacePortion, localName);
-        }
     }
 
     public boolean isPersistent() {