Skip to content

Handle and map errors in delete pending segments API#15673

Merged
kfaraz merged 6 commits intoapache:masterfrom
abhishekrb19:pending_segments_delete_err
Jan 15, 2024
Merged

Handle and map errors in delete pending segments API#15673
kfaraz merged 6 commits intoapache:masterfrom
abhishekrb19:pending_segments_delete_err

Conversation

@abhishekrb19
Copy link
Copy Markdown
Contributor

@abhishekrb19 abhishekrb19 commented Jan 12, 2024

Problem:
At present, any exception in the delete pending segments API would result in the client not knowing the correct HTTP status code and cause. Following is an error logged in the overlord logs when the delete failed, but the reason doesn't get propagated to the client:

 2024-01-12T01:06:41,807 ERROR [qtp1757718624-150] com.sun.jersey.spi.container.ContainerResponse - The RuntimeException could not be mapped to a response, re-throwing to the HTTP container java.lang.IllegalArgumentException: Cannot delete pendingSegments because there is at least one active task created at 2024-01-12T01:06:41.318Z

This patch handles the exception and maps it to a 400 response with the appropriate error message.
Also, clean up the exception messages, use DruidException, and add unit tests for these failure scenarios.

This PR has:

  • been self-reviewed.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • been tested in a test Druid cluster.

…ode.

Currently, any errors in the delete pending segments API would result
in the client not knowing about the http status and reason. This patch fixes it.

This is the error from the overlord logs that don't get mapped:
2024-01-12T01:06:41,807 ERROR [qtp1757718624-150] com.sun.jersey.spi.container.ContainerResponse - The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
java.lang.IllegalArgumentException: Cannot delete pendingSegments because there is at least one active task created at 2024-01-12T01:06:41.318Z

Also, clean up the exception messages and add tests.
Copy link
Copy Markdown
Contributor

@kfaraz kfaraz left a comment

Choose a reason for hiding this comment

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

Change makes sense, left minor comment regarding the returned HTTP status code.

@zachjsh zachjsh self-requested a review January 12, 2024 22:46
Copy link
Copy Markdown
Contributor

@zachjsh zachjsh left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@kfaraz kfaraz left a comment

Choose a reason for hiding this comment

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

Minor nitpicks, otherwise LGTM

public class IndexerMetadataStorageAdapterTest
{
@Rule
public ExpectedException expectedException = ExpectedException.none();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for removing this!

NoopTask.create()
),
new TaskInfo<>(
"id1",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch!

@kfaraz kfaraz merged commit 08c01f1 into apache:master Jan 15, 2024
@abhishekrb19 abhishekrb19 deleted the pending_segments_delete_err branch January 15, 2024 17:04
@abhishekrb19
Copy link
Copy Markdown
Contributor Author

Thanks for the reviews @kfaraz and @zachjsh!

@LakshSingla LakshSingla added this to the 29.0.0 milestone Jan 29, 2024
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.

4 participants