You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "poorbarcode (via GitHub)" <gi...@apache.org> on 2025/04/21 15:35:37 UTC

[PR] [fix][admin]Backlog quota's policy is null which causes a NPE [pulsar]

poorbarcode opened a new pull request, #24192:
URL: https://github.com/apache/pulsar/pull/24192

   ### 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
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: x


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][admin]Backlog quota's policy is null which causes a NPE [pulsar]

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- closed pull request #24192: [fix][admin]Backlog quota's policy is null which causes a NPE
URL: https://github.com/apache/pulsar/pull/24192


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][admin]Backlog quota's policy is null which causes a NPE [pulsar]

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on PR #24192:
URL: https://github.com/apache/pulsar/pull/24192#issuecomment-2818881710

   /pulsarbot rerun-failure-checks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][admin] Backlog quota's policy is null which causes a NPE [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari merged PR #24192:
URL: https://github.com/apache/pulsar/pull/24192


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][admin]Backlog quota's policy is null which causes a NPE [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #24192:
URL: https://github.com/apache/pulsar/pull/24192#discussion_r2054343224


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java:
##########
@@ -3286,6 +3290,34 @@ public void testSetSubRateWithNoSub() throws Exception {
                 .build());
     }
 
+    /**
+     * Verify: {@link BacklogQuota#getPolicy()} can not be null.
+     */
+    @Test
+    public void testSetNonBacklogQuotType() throws Exception {
+        final NamespaceName ns = NamespaceName.get(myNamespace);
+        final String hostAndPort = pulsar.getWebServiceAddress();
+        final String nsPath = "/admin/v2/namespaces/" + ns + "/backlogQuota";
+        final String topicPath = "/admin/v2/persistent/" + ns + "/test-set-backlog-quota/backlogQuota";
+        admin.namespaces().setBacklogQuota(ns.toString(), BacklogQuota.builder().limitTime(1).limitSize(1).retentionPolicy(
+                BacklogQuota.RetentionPolicy.consumer_backlog_eviction).build());
+        BacklogQuota backlogQuotaWithNonPolicy = BacklogQuota.builder().limitTime(1).limitSize(1).build();
+        JerseyClient httpClient = JerseyClientBuilder.createClient();

Review Comment:
   This leaks resources in the test. The `.close()` method of the `JerseyClient` instance should be called. Adding a Lombok `@Cleanup` annotation would handle it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][admin]Backlog quota's policy is null which causes a NPE [pulsar]

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #24192:
URL: https://github.com/apache/pulsar/pull/24192#discussion_r2057744541


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java:
##########
@@ -3286,6 +3290,34 @@ public void testSetSubRateWithNoSub() throws Exception {
                 .build());
     }
 
+    /**
+     * Verify: {@link BacklogQuota#getPolicy()} can not be null.
+     */
+    @Test
+    public void testSetNonBacklogQuotType() throws Exception {
+        final NamespaceName ns = NamespaceName.get(myNamespace);
+        final String hostAndPort = pulsar.getWebServiceAddress();
+        final String nsPath = "/admin/v2/namespaces/" + ns + "/backlogQuota";
+        final String topicPath = "/admin/v2/persistent/" + ns + "/test-set-backlog-quota/backlogQuota";
+        admin.namespaces().setBacklogQuota(ns.toString(), BacklogQuota.builder().limitTime(1).limitSize(1).retentionPolicy(
+                BacklogQuota.RetentionPolicy.consumer_backlog_eviction).build());
+        BacklogQuota backlogQuotaWithNonPolicy = BacklogQuota.builder().limitTime(1).limitSize(1).build();
+        JerseyClient httpClient = JerseyClientBuilder.createClient();

Review Comment:
   > The test org.apache.pulsar.broker.admin.AdminApiTest.testRetentionAndBacklogQuotaCheck fails.
   
   Fixed.
   
   > This leaks resources in the test. The .close() method of the JerseyClient instance should be called. Adding a Lombok @Cleanup annotation would handle it.
   
   Released



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][admin] Backlog quota's policy is null which causes a NPE [pulsar]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #24192:
URL: https://github.com/apache/pulsar/pull/24192#issuecomment-2829623739

   ## [Codecov](https://app.codecov.io/gh/apache/pulsar/pull/24192?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   All modified and coverable lines are covered by tests :white_check_mark:
   > Project coverage is 74.23%. Comparing base [(`bbc6224`)](https://app.codecov.io/gh/apache/pulsar/commit/bbc62245c5ddba1de4b1e7cee4ab49334bc36277?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`d4559a3`)](https://app.codecov.io/gh/apache/pulsar/commit/d4559a39e3c46efa34727da34e61c3932c9619f1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 1042 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/pulsar/pull/24192/graphs/tree.svg?width=650&height=150&src=pr&token=acYqCpsK9J&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/pulsar/pull/24192?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@             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](https://app.codecov.io/gh/apache/pulsar/pull/24192/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [inttests](https://app.codecov.io/gh/apache/pulsar/pull/24192/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `26.71% <0.00%> (+2.12%)` | :arrow_up: |
   | [systests](https://app.codecov.io/gh/apache/pulsar/pull/24192/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `23.28% <0.00%> (-1.04%)` | :arrow_down: |
   | [unittests](https://app.codecov.io/gh/apache/pulsar/pull/24192/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `73.73% <100.00%> (+0.88%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/pulsar/pull/24192?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [.../org/apache/pulsar/broker/admin/AdminResource.java](https://app.codecov.io/gh/apache/pulsar/pull/24192?src=pr&el=tree&filepath=pulsar-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fadmin%2FAdminResource.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9BZG1pblJlc291cmNlLmphdmE=) | `78.17% <100.00%> (+0.54%)` | :arrow_up: |
   | [...pache/pulsar/broker/admin/impl/NamespacesBase.java](https://app.codecov.io/gh/apache/pulsar/pull/24192?src=pr&el=tree&filepath=pulsar-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fadmin%2Fimpl%2FNamespacesBase.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9pbXBsL05hbWVzcGFjZXNCYXNlLmphdmE=) | `76.09% <100.00%> (+3.01%)` | :arrow_up: |
   | [...pulsar/broker/admin/impl/PersistentTopicsBase.java](https://app.codecov.io/gh/apache/pulsar/pull/24192?src=pr&el=tree&filepath=pulsar-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fadmin%2Fimpl%2FPersistentTopicsBase.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9pbXBsL1BlcnNpc3RlbnRUb3BpY3NCYXNlLmphdmE=) | `70.14% <100.00%> (+4.69%)` | :arrow_up: |
   | [...ache/pulsar/common/policies/data/BacklogQuota.java](https://app.codecov.io/gh/apache/pulsar/pull/24192?src=pr&el=tree&filepath=pulsar-client-admin-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fcommon%2Fpolicies%2Fdata%2FBacklogQuota.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWNsaWVudC1hZG1pbi1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3B1bHNhci9jb21tb24vcG9saWNpZXMvZGF0YS9CYWNrbG9nUXVvdGEuamF2YQ==) | `100.00% <100.00%> (ø)` | |
   
   ... and [1078 files with indirect coverage changes](https://app.codecov.io/gh/apache/pulsar/pull/24192/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][admin]Backlog quota's policy is null which causes a NPE [pulsar]

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on PR #24192:
URL: https://github.com/apache/pulsar/pull/24192#issuecomment-2819883445

   > * Pulsar CI / Build Pulsar on MacOS (pull_request)
   
   checkstyle failed


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org