You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "rsrkpatwari1234 (via GitHub)" <gi...@apache.org> on 2026/01/18 17:52:23 UTC
[PR] Fix FileNotFoundException handling in segment download API [pinot]
rsrkpatwari1234 opened a new pull request, #17523:
URL: https://github.com/apache/pinot/pull/17523
Fixes #16231
When the /segments controller API encountered a FileNotFoundException, it exhibited below issues -
1. Unnecessary retries: The segment fetcher retried 3 times even though the file didn't exist, wasting time and resources
2. Wrong HTTP status code: The API returned HTTP 500 (Internal Server Error) instead of HTTP 404 (Not Found)
3. Obscured root cause: The original FileNotFoundException was wrapped in AttemptsExceededException, making debugging difficult
In this PR, I have implemented two improvements -
1. Skip retries for FileNotFoundException: Modified `BaseSegmentFetcher` to detect FileNotFoundException in the exception cause chain and fail immediately without retrying
2. Return HTTP 404: Modified `PinotSegmentUploadDownloadRestletResource` to catch FileNotFoundException and return Response.Status.NOT_FOUND instead of 500
Unit Tests
β
4 new tests added to verify FileNotFoundException behaviour
β
All existing tests pass - no breaking changes
`bugfix`
--
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@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Fix FileNotFoundException handling in segment download API [pinot]
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on code in PR #17523:
URL: https://github.com/apache/pinot/pull/17523#discussion_r2723228922
##########
pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/BaseSegmentFetcher.java:
##########
@@ -151,4 +163,19 @@ protected void fetchSegmentToLocalWithoutRetry(URI uri, File dest)
throws Exception {
throw new UnsupportedOperationException();
}
+
+ /**
+ * Checks if the exception or its cause chain contains a FileNotFoundException.
+ * FileNotFoundException indicates the file doesn't exist and retrying won't help.
+ */
+ private boolean isFileNotFoundException(Exception e) {
+ Throwable cause = e;
+ while (cause != null) {
+ if (cause instanceof java.io.FileNotFoundException) {
+ return true;
+ }
+ cause = cause.getCause();
Review Comment:
Could this potentially cause infinite loop?
##########
pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/BaseSegmentFetcher.java:
##########
@@ -151,4 +163,19 @@ protected void fetchSegmentToLocalWithoutRetry(URI uri, File dest)
throws Exception {
throw new UnsupportedOperationException();
}
+
+ /**
+ * Checks if the exception or its cause chain contains a FileNotFoundException.
+ * FileNotFoundException indicates the file doesn't exist and retrying won't help.
+ */
+ private boolean isFileNotFoundException(Exception e) {
+ Throwable cause = e;
+ while (cause != null) {
+ if (cause instanceof java.io.FileNotFoundException) {
Review Comment:
(minor) Import 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@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Fix FileNotFoundException handling in segment download API [pinot]
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on code in PR #17523:
URL: https://github.com/apache/pinot/pull/17523#discussion_r3083215805
##########
pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/HttpSegmentFetcher.java:
##########
@@ -106,20 +108,26 @@ public void fetchSegmentToLocal(URI downloadURI, File dest)
return true;
} catch (HttpErrorStatusException e) {
int statusCode = e.getStatusCode();
- if (statusCode == HttpStatus.SC_NOT_FOUND || statusCode >= 500) {
- // Temporary exception
- // 404 is treated as a temporary exception, as the downloadURI may be backed by multiple hosts,
- // if singe host is down, can retry with another host.
Review Comment:
The new behavior ignores the previous comments.
When the host is a virtual ip, what is the expected behavior?
--
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@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Fix FileNotFoundException handling in segment download API [pinot]
Posted by "rsrkpatwari1234 (via GitHub)" <gi...@apache.org>.
rsrkpatwari1234 commented on code in PR #17523:
URL: https://github.com/apache/pinot/pull/17523#discussion_r2778958801
##########
pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/BaseSegmentFetcher.java:
##########
@@ -151,4 +163,19 @@ protected void fetchSegmentToLocalWithoutRetry(URI uri, File dest)
throws Exception {
throw new UnsupportedOperationException();
}
+
+ /**
+ * Checks if the exception or its cause chain contains a FileNotFoundException.
+ * FileNotFoundException indicates the file doesn't exist and retrying won't help.
+ */
+ private boolean isFileNotFoundException(Exception e) {
+ Throwable cause = e;
+ while (cause != null) {
+ if (cause instanceof java.io.FileNotFoundException) {
+ return true;
+ }
+ cause = cause.getCause();
Review Comment:
Modified the code to avoid redundancy but the loop is safe as longer cycles donβt occur in normal exception cause chains
--
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@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Fix FileNotFoundException handling in segment download API [pinot]
Posted by "rsrkpatwari1234 (via GitHub)" <gi...@apache.org>.
rsrkpatwari1234 commented on PR #17523:
URL: https://github.com/apache/pinot/pull/17523#issuecomment-3902245973
@Jackie-Jiang Requesting your review. The test failure seems unrelated to my change
--
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@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Fix FileNotFoundException handling in segment download API [pinot]
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on PR #17523:
URL: https://github.com/apache/pinot/pull/17523#issuecomment-3918102723
I think it is related:
```
[ERROR] BaseTableDataManagerTest.testAddNewSegmentUseLocalCopy:585 expected [Operation failed after 3 attempts] but found [org.apache.pinot.spi.filesystem.LocalPinotFS$LocalPinotFSException: java.io.FileNotFoundException: Source '' does not exist]
```
--
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@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Fix FileNotFoundException handling in segment download API [pinot]
Posted by "rsrkpatwari1234 (via GitHub)" <gi...@apache.org>.
rsrkpatwari1234 commented on PR #17523:
URL: https://github.com/apache/pinot/pull/17523#issuecomment-4361094133
The binary check failures are unrelated to the changes in this PR -
```
org.apache.pinot.spi.data.MultiValueVisitor.asSingleValueVisitor():METHOD_REMOVED,org.apache.pinot.spi.data.MultiValueVisitor.visitBigDecimal(java.math.BigDecimal[]):METHOD_REMOVED,org.apache.pinot.spi.data.MultiValueVisitor.visitBoolean(boolean[]):METHOD_REMOVED,org.apache.pinot.spi.data.MultiValueVisitor.visitBytes(byte[][]):METHOD_REMOVED,org.apache.pinot.spi.data.MultiValueVisitor.visitDouble(double[]):METHOD_REMOVED,org.apache.pinot.spi.data.MultiValueVisitor.visitFloat(float[]):METHOD_REMOVED,org.apache.pinot.spi.data.MultiValueVisitor.visitInt(int[]):METHOD_REMOVED,org.apache.pinot.spi.data.MultiValueVisitor.visitJson(java.lang.String[]):METHOD_REMOVED,org.apache.pinot.spi.data.MultiValueVisitor.visitLong(long[]):METHOD_REMOVED,org.apache.pinot.spi.data.MultiValueVisitor.visitString(java.lang.String[]):METHOD_REMOVED,org.apache.pinot.spi.data.MultiValueVisitor.visitTimestamp(long[]):METHOD_REMOVED,org.apache.pinot.spi.data.MultiValueVisitor:SUPERCLASS_REMOVED,org.apache.pin
ot.spi.data.MultiValueVisitor:CLASS_REMOVED,org.apache.pinot.spi.data.SingleValueVisitor.visitBigDecimal(java.math.BigDecimal):METHOD_REMOVED,org.apache.pinot.spi.data.SingleValueVisitor.visitBoolean(boolean):METHOD_REMOVED,org.apache.pinot.spi.data.SingleValueVisitor.visitBytes(byte[]):METHOD_REMOVED,org.apache.pinot.spi.data.SingleValueVisitor.visitDouble(double):METHOD_REMOVED,org.apache.pinot.spi.data.SingleValueVisitor.visitFloat(float):METHOD_REMOVED,org.apache.pinot.spi.data.SingleValueVisitor.visitInt(int):METHOD_REMOVED,org.apache.pinot.spi.data.SingleValueVisitor.visitJson(java.lang.String):METHOD_REMOVED,org.apache.pinot.spi.data.SingleValueVisitor.visitLong(long):METHOD_REMOVED,org.apache.pinot.spi.data.SingleValueVisitor.visitString(java.lang.String):METHOD_REMOVED,org.apache.pinot.spi.data.SingleValueVisitor.visitTimestamp(long):METHOD_REMOVED,org.apache.pinot.spi.data.SingleValueVisitor:SUPERCLASS_REMOVED,org.apache.pinot.spi.data.SingleValueVisitor:CLASS_REMOVED,org.
apache.pinot.spi.utils.CommonConstants$Accounting.DEFAULT_ENABLE_THREAD_CPU_SAMPLING:FIELD_TYPE_CHANGED,org.apache.pinot.spi.utils.CommonConstants$Accounting.DEFAULT_ENABLE_THREAD_MEMORY_SAMPLING:FIELD_TYPE_CHANGED
```
--
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@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Fix FileNotFoundException handling in segment download API [pinot]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #17523:
URL: https://github.com/apache/pinot/pull/17523#issuecomment-3866878386
### :x: 1 Tests Failed:
| Tests completed | Failed | Passed | Skipped |
|---|---|---|---|
| 17456 | 1 | 17455 | 27 |
<details><summary>View the full list of 1 :snowflake: flaky test(s)</summary>
> <pre><code class="language-python">org.apache.pinot.core.data.manager.BaseTableDataManagerTest::testAddNewSegmentUseLocalCopy</code></pre>
> **Flake rate in main:** 89.80% (Passed 10 times, Failed 88 times)
> <details><summary>Stack Traces | 1.35s run time</summary>
>
> > <pre><code class="language-python">expected [Operation failed after 3 attempts] but found [org.apache.pinot.spi.filesystem.LocalPinotFS$LocalPinotFSException: java.io.FileNotFoundException: Source '' does not exist]</code></pre>
>
> </details>
</details>
To view more test analytics, go to the [Test Analytics Dashboard](https://app.codecov.io/gh/apache/pinot/tests/rsrkpatwari1234%3Arsrkpatwari1234-16231)
<sub>π Got 3 mins? [Take this short survey](https://forms.gle/22i53Qa1CySZjA6c7) to help us improve Test Analytics.</sub>
--
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@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Fix FileNotFoundException handling in segment download API [pinot]
Posted by "rsrkpatwari1234 (via GitHub)" <gi...@apache.org>.
rsrkpatwari1234 commented on PR #17523:
URL: https://github.com/apache/pinot/pull/17523#issuecomment-3765566507
@Jackie-Jiang @ankitsultana Requesting your help in running the above workflow and reviewing the changes
--
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@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Fix FileNotFoundException handling in segment download API [pinot]
Posted by "rsrkpatwari1234 (via GitHub)" <gi...@apache.org>.
rsrkpatwari1234 commented on code in PR #17523:
URL: https://github.com/apache/pinot/pull/17523#discussion_r3174287683
##########
pinot-common/src/main/java/org/apache/pinot/common/utils/fetcher/HttpSegmentFetcher.java:
##########
@@ -106,20 +108,26 @@ public void fetchSegmentToLocal(URI downloadURI, File dest)
return true;
} catch (HttpErrorStatusException e) {
int statusCode = e.getStatusCode();
- if (statusCode == HttpStatus.SC_NOT_FOUND || statusCode >= 500) {
- // Temporary exception
- // 404 is treated as a temporary exception, as the downloadURI may be backed by multiple hosts,
- // if singe host is down, can retry with another host.
Review Comment:
Fixed the code to only fix handling for FileNotFound exception
--
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@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org