⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@rsrkpatwari1234
Copy link
Contributor

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

@rsrkpatwari1234
Copy link
Contributor Author

@Jackie-Jiang @ankitsultana Requesting your help in running the above workflow and reviewing the changes

Copy link
Contributor

@Jackie-Jiang Jackie-Jiang left a comment

Choose a reason for hiding this comment

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

Please fix the test failure

private boolean isFileNotFoundException(Exception e) {
Throwable cause = e;
while (cause != null) {
if (cause instanceof java.io.FileNotFoundException) {
Copy link
Contributor

Choose a reason for hiding this comment

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

(minor) Import it

if (cause instanceof java.io.FileNotFoundException) {
return true;
}
cause = cause.getCause();
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this potentially cause infinite loop?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid retries for FileNotFound exception in /segments controller API

2 participants