Skip to content

Conversation

@nodece
Copy link
Member

@nodece nodece commented Sep 30, 2025

Motivation

The topic existence was not checked, which could result in multiple creation events.

Modifications

  • Added a check to verify if the topic already exists before triggering creation events.

Documentation

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

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Sep 30, 2025
Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

LGTM

@nodece
Copy link
Member Author

nodece commented Oct 21, 2025

Rebase and fix test.

@Technoboy-
Copy link
Contributor

@nodece Please fix the related the failed test.

@nodece nodece force-pushed the fix-topic-creation-event branch from 6cbe2e8 to f3a7f33 Compare October 31, 2025 08:54
@lhotari
Copy link
Member

lhotari commented Nov 4, 2025

Please fix the test failure

  Error:  Tests run: 184, Failures: 1, Errors: 0, Skipped: 176, Time elapsed: 7.538 s <<< FAILURE! -- in org.apache.pulsar.broker.service.PersistentTopicTest
  Error:  org.apache.pulsar.broker.service.PersistentTopicTest.testCloseTopic -- Time elapsed: 0.028 s <<< FAILURE!
  java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletableFuture.thenApply(java.util.function.Function)" because the return value of "org.apache.pulsar.broker.namespace.NamespaceService.checkTopicExistsAsync(org.apache.pulsar.common.naming.TopicName)" is null
  	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
  	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
  	at org.apache.pulsar.broker.service.PersistentTopicTest.testCloseTopic(PersistentTopicTest.java:1110)
  	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
  	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
  	at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
  	at org.testng.internal.invokers.InvokeMethodRunnable.runOne(InvokeMethodRunnable.java:47)
  	at org.testng.internal.invokers.InvokeMethodRunnable.call(InvokeMethodRunnable.java:76)
  	at org.testng.internal.invokers.InvokeMethodRunnable.call(InvokeMethodRunnable.java:11)
  	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
  	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
  	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
  	at java.base/java.lang.Thread.run(Thread.java:1583)
  Caused by: java.lang.NullPointerException: Cannot invoke "java.util.concurrent.CompletableFuture.thenApply(java.util.function.Function)" because the return value of "org.apache.pulsar.broker.namespace.NamespaceService.checkTopicExistsAsync(org.apache.pulsar.common.naming.TopicName)" is null
  	at org.apache.pulsar.broker.service.BrokerService.createPersistentTopic0(BrokerService.java:1827)
  	at org.apache.pulsar.broker.service.BrokerService.createPersistentTopic0(BrokerService.java:1806)
  	at org.apache.pulsar.broker.service.BrokerService.lambda$checkOwnershipAndCreatePersistentTopic$75(BrokerService.java:1790)
  	at java.base/java.util.concurrent.CompletableFuture.uniAcceptNow(CompletableFuture.java:757)
  	at java.base/java.util.concurrent.CompletableFuture.uniAcceptStage(CompletableFuture.java:735)
  	at java.base/java.util.concurrent.CompletableFuture.thenAccept(CompletableFuture.java:2214)
  	at org.apache.pulsar.broker.service.BrokerService.lambda$checkOwnershipAndCreatePersistentTopic$78(BrokerService.java:1787)
  	at java.base/java.util.concurrent.CompletableFuture.uniRunNow(CompletableFuture.java:819)
  	at java.base/java.util.concurrent.CompletableFuture.uniRunStage(CompletableFuture.java:803)
  	at java.base/java.util.concurrent.CompletableFuture.thenRun(CompletableFuture.java:2227)
  	at org.apache.pulsar.broker.service.BrokerService.checkOwnershipAndCreatePersistentTopic(BrokerService.java:1779)
  	at org.apache.pulsar.broker.service.BrokerService.lambda$loadOrCreatePersistentTopic$69(BrokerService.java:1717)
  	at java.base/java.util.concurrent.CompletableFuture.uniRunNow(CompletableFuture.java:819)
  	at java.base/java.util.concurrent.CompletableFuture.uniRunStage(CompletableFuture.java:803)
  	at java.base/java.util.concurrent.CompletableFuture.thenRun(CompletableFuture.java:2227)
  	at org.apache.pulsar.broker.service.BrokerService.loadOrCreatePersistentTopic(BrokerService.java:1713)
  	at org.apache.pulsar.broker.service.BrokerService.loadOrCreatePersistentTopic(BrokerService.java:1710)
  	at org.apache.pulsar.broker.service.BrokerService.lambda$getTopic$39(BrokerService.java:1210)
  	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
  	at org.apache.pulsar.broker.service.BrokerService.lambda$getTopic$41(BrokerService.java:1208)
  	at java.base/java.util.concurrent.CompletableFuture.uniRunNow(CompletableFuture.java:819)
  	at java.base/java.util.concurrent.CompletableFuture.uniRunStage(CompletableFuture.java:803)
  	at java.base/java.util.concurrent.CompletableFuture.thenRun(CompletableFuture.java:2227)
  	at org.apache.pulsar.broker.service.BrokerService.lambda$getTopic$44(BrokerService.java:1206)
  	at java.base/java.util.concurrent.CompletableFuture.uniAcceptNow(CompletableFuture.java:757)
  	at java.base/java.util.concurrent.CompletableFuture.uniAcceptStage(CompletableFuture.java:735)
  	at java.base/java.util.concurrent.CompletableFuture.thenAccept(CompletableFuture.java:2214)
  	at org.apache.pulsar.broker.service.BrokerService.getTopic(BrokerService.java:1198)
  	at org.apache.pulsar.broker.service.BrokerService.getTopic(BrokerService.java:1168)
  	at org.apache.pulsar.broker.service.BrokerService.getTopic(BrokerService.java:1082)
  	at org.apache.pulsar.broker.service.BrokerService.getTopic(BrokerService.java:1077)
  	at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1187)
  	at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2341)
  	at org.apache.pulsar.broker.service.BrokerService.getOrCreateTopic(BrokerService.java:1072)
  	at org.apache.pulsar.broker.service.BrokerService.getOrCreateTopic(BrokerService.java:1071)
  	... 11 more

@lhotari
Copy link
Member

lhotari commented Nov 5, 2025

@nodece Please check the test failure in ServerCnxTest.test2ndSubFailedIfDisabledConCheck. It failed 2 times in a row

  Error:  Tests run: 270, Failures: 1, Errors: 0, Skipped: 241, Time elapsed: 10.19 s <<< FAILURE! -- in org.apache.pulsar.broker.service.ServerCnxTest
  Error:  org.apache.pulsar.broker.service.ServerCnxTest.test2ndSubFailedIfDisabledConCheck -- Time elapsed: 0.011 s <<< FAILURE!
  java.lang.AssertionError: expected [true] but found [false]
  	at org.testng.Assert.fail(Assert.java:110)
  	at org.testng.Assert.failNotEquals(Assert.java:1577)
  	at org.testng.Assert.assertTrue(Assert.java:56)
  	at org.testng.Assert.assertTrue(Assert.java:66)
  	at org.apache.pulsar.broker.service.ServerCnxTest.test2ndSubFailedIfDisabledConCheck(ServerCnxTest.java:1133)
  	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
  	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
  	at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
  	at org.testng.internal.invokers.InvokeMethodRunnable.runOne(InvokeMethodRunnable.java:47)
  	at org.testng.internal.invokers.InvokeMethodRunnable.call(InvokeMethodRunnable.java:76)
  	at org.testng.internal.invokers.InvokeMethodRunnable.call(InvokeMethodRunnable.java:11)
  	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
  	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
  	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
  	at java.base/java.lang.Thread.run(Thread.java:1583)

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.28%. Comparing base (39bb675) to head (338efcc).
⚠️ Report is 24 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24802      +/-   ##
============================================
+ Coverage     74.05%   74.28%   +0.23%     
+ Complexity    33881    33528     -353     
============================================
  Files          1886     1913      +27     
  Lines        148922   149510     +588     
  Branches      17300    17373      +73     
============================================
+ Hits         110277   111067     +790     
+ Misses        29836    29579     -257     
- Partials       8809     8864      +55     
Flag Coverage Δ
inttests 26.27% <100.00%> (-0.24%) ⬇️
systests 22.75% <100.00%> (?)
unittests 73.81% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...rg/apache/pulsar/broker/service/BrokerService.java 83.44% <100.00%> (-0.06%) ⬇️

... and 184 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodece
Copy link
Member Author

nodece commented Nov 6, 2025

@Technoboy- @lhotari Could you review this PR again?

@nodece nodece requested review from Technoboy- and dao-jun November 6, 2025 07:17
Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

LGTM

@lhotari lhotari merged commit d168ab8 into apache:master Nov 6, 2025
96 of 100 checks passed
lhotari pushed a commit that referenced this pull request Nov 11, 2025
lhotari pushed a commit that referenced this pull request Nov 11, 2025
lhotari pushed a commit that referenced this pull request Nov 11, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 13, 2025
… topic (apache#24802)

(cherry picked from commit d168ab8)
(cherry picked from commit 29fcac4)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 13, 2025
… topic (apache#24802)

(cherry picked from commit d168ab8)
(cherry picked from commit 29fcac4)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 13, 2025
… topic (apache#24802)

(cherry picked from commit d168ab8)
(cherry picked from commit f8069df)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 14, 2025
… topic (apache#24802)

(cherry picked from commit d168ab8)
(cherry picked from commit f8069df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants