Skip to content

Conversation

@poorbarcode
Copy link
Contributor

Motivation

  • pulsar-admin namespaces set-backlog-quota <namespace> does not allow a null attribute policy, but HTTP API POST /admin/v2/namespaces/{namespace}/backlogQuota allows.
  • pulsar-admin topicPolicies set-backlog-quota <namespace> does not allow a null attribute policy, but HTTP API POST /admin/v2/namespaces/{topic}/backlogQuota allows.

It leads a NPE

2025-04-21T03:04:02,254+0000 [pulsar-backlog-quota-checker-OrderedScheduler-0-0] INFO  org.apache.pulsar.broker.service.BacklogQuotaManager - Backlog quota type destination_storage exceeded for topic [persistent://public/default/internal-partition-1]. Applying [null] policy
2025-04-21T03:04:02,254+0000 [pulsar-backlog-quota-checker-OrderedScheduler-0-0] ERROR org.apache.pulsar.broker.service.BrokerService - Error when checkBacklogQuota(persistent://public/default/internal-partition-1) in monitorBacklogQuota
java.util.concurrent.CompletionException: java.lang.NullPointerException: Cannot invoke "org.apache.pulsar.common.policies.data.BacklogQuota$RetentionPolicy.ordinal()" because the return value of "org.apache.pulsar.common.policies.data.BacklogQuota.getPolicy()" is null
        at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) ~[?:?]
        at java.base/java.util.concurrent.CompletableFuture.uniAcceptNow(Unknown Source) ~[?:?]
        at java.base/java.util.concurrent.CompletableFuture.uniAcceptStage(Unknown Source) ~[?:?]
        at java.base/java.util.concurrent.CompletableFuture.thenAccept(Unknown Source) ~[?:?]
        at org.apache.pulsar.broker.service.BrokerService.lambda$monitorBacklogQuota$104(BrokerService.java:2221) ~[io.streamnative-pulsar-broker-3.3.5.jar:3.3.5]
        at org.apache.pulsar.broker.service.BrokerService.lambda$forEachPersistentTopic$99(BrokerService.java:2211) ~[io.streamnative-pulsar-broker-3.3.5.jar:3.3.5]
        at java.base/java.util.Optional.ifPresent(Unknown Source) ~[?:?]
        at org.apache.pulsar.broker.service.BrokerService.lambda$forEachPersistentTopic$100(BrokerService.java:2211) ~[io.streamnative-pulsar-broker-3.3.5.jar:3.3.5]
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source) ~[?:?]
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) ~[?:?]
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) ~[?:?]
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source) ~[?:?]
        at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[?:?]
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[?:?]
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source) ~[?:?]
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source) ~[?:?]
        at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[?:?]
        at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source) ~[?:?]
        at org.apache.pulsar.broker.service.BrokerService.forEachPersistentTopic(BrokerService.java:2211) ~[io.streamnative-pulsar-broker-3.3.5.jar:3.3.5]
        at org.apache.pulsar.broker.service.BrokerService.monitorBacklogQuota(BrokerService.java:2220) ~[io.streamnative-pulsar-broker-3.3.5.jar:3.3.5]
        at com.google.common.util.concurrent.MoreExecutors$ScheduledListeningDecorator$NeverSuccessfulListenableFutureTask.run(MoreExecutors.java:741) ~[com.google.guava-guava-32.1.2-jre.jar:?]
        at org.apache.bookkeeper.common.util.SingleThreadSafeScheduledExecutorService$SafeRunnable.run(SingleThreadSafeScheduledExecutorService.java:45) ~[io.streamnative-bookkeeper-common-4.17.1.2.jar:4.17.1.2]
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:?]
        at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source) ~[?:?]
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) ~[?:?]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[io.netty-netty-common-4.1.119.Final.jar:4.1.119.Final]
        at java.base/java.lang.Thread.run(Unknown Source) [?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.pulsar.common.policies.data.BacklogQuota$RetentionPolicy.ordinal()" because the return value of "org.apache.pulsar.common.policies.data.BacklogQuota.getPolicy()" is null
        at org.apache.pulsar.broker.service.BacklogQuotaManager.handleExceededBacklogQuota(BacklogQuotaManager.java:93) ~[io.streamnative-pulsar-broker-3.3.5.jar:3.3.5]
        at org.apache.pulsar.broker.service.BrokerService.lambda$monitorBacklogQuota$102(BrokerService.java:2223) ~[io.streamnative-pulsar-broker-3.3.5.jar:3.3.5]
        ... 28 more
2025-04-21T03:04:02,256+0000 [pulsar-backlog-quota-checker-OrderedScheduler-0-0] INFO  org.apache.pulsar.broker.service.BacklogQuotaManager - Backlog quota type destination_storage exceeded for topic [persistent://public/default/output-partition-1]. Applying [null] policy

Modifications

Let HTTP API does not allow the null policy as well

Documentation

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

Matching PR in forked repository

PR in forked repository: x

@poorbarcode poorbarcode added type/bug The PR fixed a bug or issue reported a bug release/3.0.12 release/3.3.7 release/4.0.5 labels Apr 21, 2025
@poorbarcode poorbarcode added this to the 4.1.0 milestone Apr 21, 2025
@poorbarcode poorbarcode requested a review from zymap April 21, 2025 15:35
@poorbarcode poorbarcode self-assigned this Apr 21, 2025
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Apr 21, 2025
@poorbarcode
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@Technoboy- Technoboy- closed this Apr 22, 2025
@Technoboy- Technoboy- reopened this Apr 22, 2025
@Technoboy-
Copy link
Contributor

  • Pulsar CI / Build Pulsar on MacOS (pull_request)

checkstyle failed

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.

The test org.apache.pulsar.broker.admin.AdminApiTest.testRetentionAndBacklogQuotaCheck fails.

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 changed the title [fix][admin]Backlog quota's policy is null which causes a NPE [fix][admin] Backlog quota's policy is null which causes a NPE Apr 24, 2025
@codecov-commenter
Copy link

codecov-commenter commented Apr 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.23%. Comparing base (bbc6224) to head (d4559a3).
Report is 1047 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24192      +/-   ##
============================================
+ Coverage     73.57%   74.23%   +0.65%     
+ Complexity    32624    32178     -446     
============================================
  Files          1877     1866      -11     
  Lines        139502   144750    +5248     
  Branches      15299    16534    +1235     
============================================
+ Hits         102638   107448    +4810     
+ Misses        28908    28811      -97     
- Partials       7956     8491     +535     
Flag Coverage Δ
inttests 26.71% <0.00%> (+2.12%) ⬆️
systests 23.28% <0.00%> (-1.04%) ⬇️
unittests 73.73% <100.00%> (+0.88%) ⬆️

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

Files with missing lines Coverage Δ
.../org/apache/pulsar/broker/admin/AdminResource.java 78.17% <100.00%> (+0.54%) ⬆️
...pache/pulsar/broker/admin/impl/NamespacesBase.java 76.09% <100.00%> (+3.01%) ⬆️
...pulsar/broker/admin/impl/PersistentTopicsBase.java 70.14% <100.00%> (+4.69%) ⬆️
...ache/pulsar/common/policies/data/BacklogQuota.java 100.00% <100.00%> (ø)

... and 1078 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.

@lhotari lhotari merged commit cb018d9 into apache:master Apr 25, 2025
52 checks passed
lhotari pushed a commit that referenced this pull request Apr 25, 2025
lhotari pushed a commit that referenced this pull request Apr 25, 2025
lhotari pushed a commit that referenced this pull request Apr 25, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 30, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 30, 2025
ganesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 30, 2025
ganesh-ctds pushed a commit to datastax/pulsar that referenced this pull request May 1, 2025
ganesh-ctds pushed a commit to datastax/pulsar that referenced this pull request May 1, 2025
ganesh-ctds pushed a commit to datastax/pulsar that referenced this pull request May 1, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request May 2, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request May 2, 2025
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request May 6, 2025
nodece pushed a commit to ascentstream/pulsar that referenced this pull request May 28, 2025
KannarFr pushed a commit to CleverCloud/pulsar that referenced this pull request Sep 22, 2025
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
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.

7 participants