-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Pinot returns corresponding http response code for errors #17341
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
Pinot returns corresponding http response code for errors #17341
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #17341 +/- ##
============================================
+ Coverage 63.28% 63.32% +0.04%
Complexity 1474 1474
============================================
Files 3135 3135
Lines 186477 186608 +131
Branches 28495 28511 +16
============================================
+ Hits 118006 118176 +170
+ Misses 59357 59306 -51
- Partials 9114 9126 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Jackie-Jiang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly good. Well done
| IN_PROGRESS, // The segment is still consuming data | ||
| COMMITTING, // This state will only be utilised by pauseless ingestion when the segment has been consumed but | ||
| // is yet to be build and uploaded by the server. | ||
| // is yet to be build and uploaded by the server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) Revert
| public static final String SEGMENT_NAME_HTTP_HEADER = "Pinot-Segment-Name"; | ||
| public static final String TABLE_NAME_HTTP_HEADER = "Pinot-Table-Name"; | ||
| public static final String PINOT_QUERY_ERROR_CODE_HEADER = "X-Pinot-Error-Code"; | ||
| public static final String PINOT_HTTP_RESPONSE_CODE_REPRESENT_ERROR_HEADER = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This header is for broker request, not controller.
Seems the recent standard deprecated the X- prefix, so I'd suggest naming it Pinot-Use-Http-Status-For-Errors
pinot-spi/pom.xml
Outdated
| <artifactId>assertj-core</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this above (probably above plexus-classworlds) and fix the indentation
| queryErrorCodeHeaderValue = exceptions.get(0).getErrorCode(); | ||
|
|
||
| // Check if the client wants actual HTTP error codes instead of 200 OK | ||
| if ("true".equalsIgnoreCase(httpHeaders.getHeaderString( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(minor) Use Boolean.parseBoolean()
|
@Jackie-Jiang addressed feedback, thanks |
Jackie-Jiang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with minor comments
| "pinot.broker.use.mse.to.fill.empty.response.schema"; | ||
| public static final boolean DEFAULT_USE_MSE_TO_FILL_EMPTY_RESPONSE_SCHEMA = false; | ||
|
|
||
| public static final String PINOT_USE_HTTP_STATUS_FOR_ERRORS_HEADER = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public static final String PINOT_USE_HTTP_STATUS_FOR_ERRORS_HEADER = | |
| public static final String USE_HTTP_STATUS_FOR_ERRORS_HEADER = |
| * | ||
| * @param brokerResponse | ||
| * By default, returns HTTP 200 OK even for errors. If the request header | ||
| * 'X-PINOT-HTTP-RESPONSE-CODE-REPRESENT-ERROR' is set to 'true', returns appropriate HTTP status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update this
|
@Jackie-Jiang updated, can you merge this after build pass? |
BLUF
This PR addresses #17329, adds support to let Pinot broker return corresponding http response error code when query ends up with exceptions, instead of always returning 200
Problem
Pinot today always returns 200 with exceptions list in query response. Client cannot simply depend on the response code to know if the query succeeds or not. There are some use cases that are not easy to explode the response to check query result. For example, outlier detection implemented at the L7 networking layer. So there are needs to let Pinot http response code reflect the actual query response status
Solution
To make this change backward-compatible, we introduced a request header
X-PINOT-HTTP-RESPONSE-CODE-REPRESENT-ERRORto indicate Pinot should return http response code representing actual error instead of 200 when it's set to true. So this won't affect all existing use cases, client can make the decision by configuring the header when sending the request.We also introduced a mapping of http response code <> pinot error code. This should be update when new error code is added, otherwise default to 500
Test
We tested on our test cluster by sending request to a non-existent table, we got 200 back with Pinot error code 450
Then we send the same request with the header set to true, this time we got 500 back which is the corresponding http response code of 450