You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "qiref (via GitHub)" <gi...@apache.org> on 2025/12/18 02:22:37 UTC
[PR] [hotfix][metrics] Fix NullArgumentException when calculating checkpoint statistics with empty data [flink]
qiref opened a new pull request, #27348:
URL: https://github.com/apache/flink/pull/27348
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
When a Flink job starts without any checkpoint data, the DescriptiveStatisticsHistogramStatistics
may be initialized with an empty array. The maybeInitPercentile() method only checked for null but not for empty arrays, causing Apache Commons Math's Percentile.evaluate() to throw a NullArgumentException when accessing the checkpoint statistics page in the Web UI.
``` java
org.apache.commons.math3.exception.NullArgumentException: input array
at org.apache.commons.math3.util.MathArrays.verifyValues(MathArrays.java:1753) ~[commons-math3-3.6.1.jar:3.6.1]
at org.apache.commons.math3.stat.descriptive.AbstractUnivariateStatistic.test(AbstractUnivariateStatistic.java:158) ~[commons-math3-3.6.1.jar:3.6.1]
at org.apache.commons.math3.stat.descriptive.rank.Percentile.evaluate(Percentile.java:272) ~[commons-math3-3.6.1.jar:3.6.1]
at org.apache.commons.math3.stat.descriptive.rank.Percentile.evaluate(Percentile.java:241) ~[commons-math3-3.6.1.jar:3.6.1]
at org.apache.flink.runtime.metrics.DescriptiveStatisticsHistogramStatistics$CommonMetricsSnapshot.getPercentile(DescriptiveStatisticsHistogramStatistics.java:163) ~[classes/:?]
at org.apache.flink.runtime.metrics.DescriptiveStatisticsHistogramStatistics.getQuantile(DescriptiveStatisticsHistogramStatistics.java:57) ~[classes/:?]
at org.apache.flink.runtime.checkpoint.StatsSummarySnapshot.getQuantile(StatsSummarySnapshot.java:108) ~[classes/:?]
at org.apache.flink.runtime.rest.messages.checkpoints.StatsSummaryDto.valueOf(StatsSummaryDto.java:81) ~[classes/:?]
at org.apache.flink.runtime.rest.handler.job.checkpoints.CheckpointingStatisticsHandler.createCheckpointingStatistics(CheckpointingStatisticsHandler.java:128) ~[classes/:?]
at org.apache.flink.runtime.rest.handler.job.checkpoints.CheckpointingStatisticsHandler.handleCheckpointStatsRequest(CheckpointingStatisticsHandler.java:85) ~[classes/:?]
at org.apache.flink.runtime.rest.handler.job.checkpoints.CheckpointingStatisticsHandler.handleCheckpointStatsRequest(CheckpointingStatisticsHandler.java:59) ~[classes/:?]
at org.apache.flink.runtime.rest.handler.job.checkpoints.AbstractCheckpointStatsHandler.lambda$handleRequest$1(AbstractCheckpointStatsHandler.java:89) ~[classes/:?]
at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:616) [?:1.8.0_432]
at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:591) [?:1.8.0_432]
at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:456) [?:1.8.0_432]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_432]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_432]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_432]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_432]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_432]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_432]
at java.lang.Thread.run(Thread.java:750) [?:1.8.0_432]
```
## Brief change log
This commit adds an additional check for empty arrays in the maybeInitPercentile() method. When the data array is null or empty, it now uses a default array {0.0} to avoid the exception while maintaining reasonable default values for all percentile calculations.
## Verifying this change
This change is already covered by existing tests, such as:
- `DescriptiveStatisticsHistogramTest` - Tests the histogram statistics calculation with various data scenarios
- The existing tests continue to pass with this change, and the fix prevents the `NullArgumentException` in production scenarios
**Manual Verification:**
- Started a Flink cluster with a streaming job that has no checkpoint configured
- Accessed the checkpoint statistics page in Web UI (`http://localhost:8081/#/job/<job-id>/checkpoints`)
- Verified that the page loads successfully without throwing `NullArgumentException`
- After enabling checkpoints and completing some checkpoints, verified that real statistics are calculated correctly
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (no)
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [hotfix][metrics] Fix NullArgumentException when calculating checkpoint statistics with empty data [flink]
Posted by "qiref (via GitHub)" <gi...@apache.org>.
qiref commented on code in PR #27348:
URL: https://github.com/apache/flink/pull/27348#discussion_r2870809062
##########
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/DescriptiveStatisticsHistogramStatistics.java:
##########
@@ -172,7 +172,7 @@ private void maybeInitPercentile() {
if (percentilesImpl == null) {
percentilesImpl = new Percentile().withNaNStrategy(NaNStrategy.FIXED);
}
- if (data != null) {
+ if (data != null && data.length > 0) {
Review Comment:
@davidradl Ready for re-review
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [hotfix][metrics] Fix NullArgumentException when calculating checkpoint statistics with empty data [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #27348:
URL: https://github.com/apache/flink/pull/27348#discussion_r2630179611
##########
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/DescriptiveStatisticsHistogramStatistics.java:
##########
@@ -172,7 +172,7 @@ private void maybeInitPercentile() {
if (percentilesImpl == null) {
percentilesImpl = new Percentile().withNaNStrategy(NaNStrategy.FIXED);
}
- if (data != null) {
+ if (data != null && data.length > 0) {
Review Comment:
Looks good. Could we have a unit test for this please?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [hotfix][metrics] Fix NullArgumentException when calculating checkpoint statistics with empty data [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #27348:
URL: https://github.com/apache/flink/pull/27348#discussion_r2630179611
##########
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/DescriptiveStatisticsHistogramStatistics.java:
##########
@@ -172,7 +172,7 @@ private void maybeInitPercentile() {
if (percentilesImpl == null) {
percentilesImpl = new Percentile().withNaNStrategy(NaNStrategy.FIXED);
}
- if (data != null) {
+ if (data != null && data.length > 0) {
Review Comment:
Looks good. Could we have a unit test for this please? Maybe at the level that hit the NullArgumentException.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [hotfix][metrics] Fix NullArgumentException when calculating checkpoint statistics with empty data [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #27348:
URL: https://github.com/apache/flink/pull/27348#issuecomment-3668014573
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "3119b5466adc605a9fc13dcf1c577c23c5beba22",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "3119b5466adc605a9fc13dcf1c577c23c5beba22",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 3119b5466adc605a9fc13dcf1c577c23c5beba22 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [hotfix][metrics] Fix NullArgumentException when calculating checkpoint statistics with empty data [flink]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27348:
URL: https://github.com/apache/flink/pull/27348#issuecomment-4586069935
This PR is being marked as stale since it has not had any activity in the last 90 days.
If you would like to keep this PR alive, please leave a comment asking for a review.
If the PR has merge conflicts, update it with the latest from the base branch.
If you are having difficulty finding a reviewer, please reach out to the
community, contact details can be found here: https://flink.apache.org/what-is-flink/community/
If this PR is no longer valid or desired, please feel free to close it.
If no activity occurs in the next 30 days, it will be automatically closed.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [hotfix][metrics] Fix NullArgumentException when calculating checkpoint statistics with empty data [flink]
Posted by "qiref (via GitHub)" <gi...@apache.org>.
qiref commented on code in PR #27348:
URL: https://github.com/apache/flink/pull/27348#discussion_r2633557786
##########
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/DescriptiveStatisticsHistogramStatistics.java:
##########
@@ -172,7 +172,7 @@ private void maybeInitPercentile() {
if (percentilesImpl == null) {
percentilesImpl = new Percentile().withNaNStrategy(NaNStrategy.FIXED);
}
- if (data != null) {
+ if (data != null && data.length > 0) {
Review Comment:
Done! Added tests that specifically target the NullArgumentException scenario. The bug is now immortalized in our test suite. Tests can be verified with:
```
mvn test -pl flink-runtime -Dtest=DescriptiveStatisticsHistogramTest
```
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [hotfix][metrics] Fix NullArgumentException when calculating checkpoint statistics with empty data [flink]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27348:
URL: https://github.com/apache/flink/pull/27348#issuecomment-4840992985
This PR has been closed since it has not had any activity in 120 days.
If you feel like this was a mistake, or you would like to continue working on it,
please feel free to re-open the PR and ask for a review.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [hotfix][metrics] Fix NullArgumentException when calculating checkpoint statistics with empty data [flink]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #27348: [hotfix][metrics] Fix NullArgumentException when calculating checkpoint statistics with empty data
URL: https://github.com/apache/flink/pull/27348
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org