Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent NPE when attempt to fetch partition information fails #11769

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

rajagopr
Copy link
Contributor

@rajagopr rajagopr commented Oct 9, 2023

Changes are to prevent the NPE and provide a meaningful error message to the user when there is a failure to fetch the partition information.

NPE seen by the end user who created a Kafka topic without any partitions in a third-party managed Kafka cluster.

Caused by: java.lang.NullPointerException
        at org.apache.pinot.plugin.stream.kafka20.KafkaStreamMetadataProvider.fetchPartitionCount(KafkaStreamMetadataProvider.java:60) ~[startree-write-api-0.13.0-ST.98.3-shaded.jar:0.13.0-ST.98.3-1eb9c04b445be445d976f47c790dddaed274298d]
        at org.apache.pinot.spi.stream.StreamMetadataProvider.computePartitionGroupMetadata(StreamMetadataProvider.java:68) ~[startree-pinot-all-0.13.0-ST.98.3-jar-with-dependencies.jar:0.13.0-ST.98.3-1eb9c04b445be445d976f47c790dddaed274298d]
        at org.apache.pinot.spi.stream.PartitionGroupMetadataFetcher.call(PartitionGroupMetadataFetcher.java:70) ~[startree-pinot-all-0.13.0-ST.98.3-jar-with-dependencies.jar:0.13.0-ST.98.3-1eb9c04b445be445d976f47c790dddaed274298d]
        at org.apache.pinot.spi.stream.PartitionGroupMetadataFetcher.call(PartitionGroupMetadataFetcher.java:31) ~[startree-pinot-all-0.13.0-ST.98.3-jar-with-dependencies.jar:0.13.0-ST.98.3-1eb9c04b445be445d976f47c790dddaed274298d]
        at org.apache.pinot.spi.utils.retry.BaseRetryPolicy.attempt(BaseRetryPolicy.java:50) ~[startree-pinot-all-0.13.0-ST.98.3-jar-with-dependencies.jar:0.13.0-ST.98.3-1eb9c04b445be445d976f47c790dddaed274298d]
        at org.apache.pinot.controller.helix.core.PinotTableIdealStateBuilder.getPartitionGroupMetadataList(PinotTableIdealStateBuilder.java:160) ~[startree-pinot-all-0.13.0-ST.98.3-jar-with-dependencies.jar:0.13.0-ST.98.3-1eb9c04b445be445d976f47c790dddaed274298d]
        ... 31 more

Notes: Unable to add a test using mocks as the class KafkaPartitionLevelConnectionHandler declares the consumer as final within it's constructor. Additionally, the Kafka library always creates a default partition (0) when creating the Kafka topic.

@codecov-commenter
Copy link

codecov-commenter commented Oct 10, 2023

Codecov Report

Merging #11769 (1c68b99) into master (13c2901) will decrease coverage by 0.02%.
Report is 4 commits behind head on master.
The diff coverage is 50.00%.

@@             Coverage Diff              @@
##             master   #11769      +/-   ##
============================================
- Coverage     63.13%   63.12%   -0.02%     
  Complexity     1117     1117              
============================================
  Files          2342     2342              
  Lines        125916   125920       +4     
  Branches      19370    19371       +1     
============================================
- Hits          79501    79489      -12     
- Misses        40749    40768      +19     
+ Partials       5666     5663       -3     
Flag Coverage Δ
integration <0.01% <0.00%> (ø)
integration1 <0.01% <0.00%> (ø)
integration2 0.00% <0.00%> (ø)
java-11 63.05% <50.00%> (-0.02%) ⬇️
java-17 62.97% <50.00%> (+0.02%) ⬆️
java-20 62.96% <50.00%> (-0.03%) ⬇️
temurin 63.12% <50.00%> (-0.02%) ⬇️
unittests 63.12% <50.00%> (-0.02%) ⬇️
unittests1 67.23% <ø> (+<0.01%) ⬆️
unittests2 14.45% <50.00%> (-0.02%) ⬇️

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

Files Coverage Δ
...in/stream/kafka20/KafkaStreamMetadataProvider.java 44.61% <50.00%> (-0.55%) ⬇️

... and 16 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@snleee snleee left a comment

Choose a reason for hiding this comment

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

Is it easy to add the testing case for this?

@snleee snleee merged commit cdd16fe into apache:master Oct 11, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants