You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/07/05 06:03:09 UTC

[GitHub] [pulsar] lordcheng10 opened a new pull request, #16392: fix npe when filterEntriesForConsumer

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

   ### Motivation
   An npe exception was found in the exception logļ¼š
   <img width="1460" alt="image" src="https://user-images.githubusercontent.com/19296967/177259582-474750fb-ebbc-45de-afa6-e2e8c70726d0.png">
   
   By analyzing the code, it is found that in the filterEntriesForConsumer method, some entries may have been released, resulting in entry.getDataBuffer() is null. So we need to skip these entries.
   
   
   ### Documentation
   
   Check the box below or label this PR directly.
   
   Need to update docs? 
   
   - [ ] `doc-required` 
   (Your PR needs to update docs and you will update later)
     
   - [x] `doc-not-needed` 
   (Please explain why)
     
   - [ ] `doc` 
   (Your PR contains doc changes)
   
   - [ ] `doc-complete`
   (Docs have been already added)


-- 
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


[GitHub] [pulsar] tisonkun commented on pull request #16392: [fix][broker]fix npe when filterEntriesForConsumer

Posted by GitBox <gi...@apache.org>.
tisonkun commented on PR #16392:
URL: https://github.com/apache/pulsar/pull/16392#issuecomment-1313140859

   Closed as stale.
   
   From https://github.com/apache/pulsar/pull/16392#discussion_r913430722 I don't think this patch is active.


-- 
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


[GitHub] [pulsar] lordcheng10 commented on a diff in pull request #16392: [fix][broker]fix npe when filterEntriesForConsumer

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on code in PR #16392:
URL: https://github.com/apache/pulsar/pull/16392#discussion_r913444704


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java:
##########
@@ -127,7 +127,7 @@ public int filterEntriesForConsumer(Optional<MessageMetadata[]> optMetadataArray
         List<PositionImpl> entriesToRedeliver = CollectionUtils.isNotEmpty(entryFilters) ? new ArrayList<>() : null;
         for (int i = 0, entriesSize = entries.size(); i < entriesSize; i++) {
             Entry entry = entries.get(i);
-            if (entry == null) {
+            if (entry == null || entry.getDataBuffer() == null) {

Review Comment:
   OK ,thanks!



-- 
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


[GitHub] [pulsar] BewareMyPower commented on a diff in pull request #16392: [fix][broker]fix npe when filterEntriesForConsumer

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on code in PR #16392:
URL: https://github.com/apache/pulsar/pull/16392#discussion_r913430722


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java:
##########
@@ -127,7 +127,7 @@ public int filterEntriesForConsumer(Optional<MessageMetadata[]> optMetadataArray
         List<PositionImpl> entriesToRedeliver = CollectionUtils.isNotEmpty(entryFilters) ? new ArrayList<>() : null;
         for (int i = 0, entriesSize = entries.size(); i < entriesSize; i++) {
             Entry entry = entries.get(i);
-            if (entry == null) {
+            if (entry == null || entry.getDataBuffer() == null) {

Review Comment:
   First, it's better to check `metadataAndPayload == null` to reduce one more invocation of `getDataBuffer()`.
   
   Then, we should not resolve this issue by just adding a null check. `entry.getDataBuffer() == null` represents this entry has already been recycled. However, the corresponding item of a recycled entry in the entry list (`entries`) is usually set null, for example:
   
   https://github.com/apache/pulsar/blob/926834ef8b2b57d3964aa7e9773e6245bcee861c/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java#L142-L143
   
   Instead of null check simply, we should figure out in which case could `entries.get(i)` return a non-null entry that is recycled. In addition, I found your Pulsar version is 2.8.1.2, you might check the 2.8.1.2 source code first because there were many changes in master since that.



-- 
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


[GitHub] [pulsar] github-actions[bot] commented on pull request #16392: [fix][broker]fix npe when filterEntriesForConsumer

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #16392:
URL: https://github.com/apache/pulsar/pull/16392#issuecomment-1205963395

   The pr had no activity for 30 days, mark with Stale label.


-- 
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


[GitHub] [pulsar] tisonkun closed pull request #16392: [fix][broker]fix npe when filterEntriesForConsumer

Posted by GitBox <gi...@apache.org>.
tisonkun closed pull request #16392: [fix][broker]fix npe when filterEntriesForConsumer
URL: https://github.com/apache/pulsar/pull/16392


-- 
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