Skip to content
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

[query] Handle context.Canceled and map to 4xx http status #3069

Merged
merged 5 commits into from
Jan 26, 2021

Conversation

Antanukas
Copy link
Collaborator

@Antanukas Antanukas commented Jan 8, 2021

What this PR does / why we need it:

Handles context.Canceled on query side.

Special notes for your reviewer:

NONE

Does this PR introduce a user-facing and/or backwards incompatible change?:

context.Cancel should usually happen when the client is not expecting response anymore so this should not be a breaking change.

Handles context.Canceled and maps to a 4xx instead of 5xx http status

Does this PR require updating code package or user-facing documentation?:

NONE

@Antanukas Antanukas marked this pull request as ready for review January 8, 2021 18:24
@codecov
Copy link

codecov bot commented Jan 8, 2021

Codecov Report

Merging #3069 (23be4b9) into master (358d92a) will increase coverage by 0.0%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3069   +/-   ##
=======================================
  Coverage    72.2%    72.2%           
=======================================
  Files        1084     1084           
  Lines      100199   100201    +2     
=======================================
+ Hits        72346    72399   +53     
+ Misses      22797    22761   -36     
+ Partials     5056     5041   -15     
Flag Coverage Δ
aggregator 75.8% <ø> (+<0.1%) ⬆️
cluster 84.8% <ø> (ø)
collector 84.3% <ø> (ø)
dbnode 78.6% <ø> (+<0.1%) ⬆️
m3em 74.4% <ø> (ø)
m3ninx 73.1% <ø> (ø)
metrics 20.0% <ø> (ø)
msg 74.3% <ø> (+0.6%) ⬆️
query 67.2% <ø> (ø)
x 80.3% <100.0%> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 358d92a...23be4b9. Read the comment docs.

@@ -132,7 +132,7 @@ func getStatusCode(err error) int {
case Error:
return v.Code()
case error:
if xerrors.IsInvalidParams(v) {
if xerrors.IsInvalidParams(v) || errors.Is(err, context.Canceled) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this should be http.StatusGatewayTimeout since this is the same as the context deadline being exceeded, essentially a timeout.

Copy link
Collaborator Author

@Antanukas Antanukas Jan 8, 2021

Choose a reason for hiding this comment

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

Hmm well StatusGatewayTimeout is 504, but contextCanceled means client canceled the request. It could happen because request took too long and client canceled. For example Nginx came up with their own non 500 status code for this case https://httpstatuses.com/499

I thought smth from 4xx range would be better then 5xx in this case. Since client just abandoned the request which did not reach specified deadline.

@Antanukas Antanukas force-pushed the antanas/ch5674/handle-context-cancel branch from 5b489e8 to ad387bf Compare January 15, 2021 09:25
Copy link
Collaborator

@robskillington robskillington left a comment

Choose a reason for hiding this comment

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

LGTM

src/x/net/http/errors_test.go Outdated Show resolved Hide resolved
src/x/net/http/errors_test.go Outdated Show resolved Hide resolved
src/x/net/http/errors_test.go Outdated Show resolved Hide resolved
@Antanukas Antanukas force-pushed the antanas/ch5674/handle-context-cancel branch from aee8aab to 9c0d605 Compare January 26, 2021 08:29
@Antanukas Antanukas merged commit 0d41634 into master Jan 26, 2021
@Antanukas Antanukas deleted the antanas/ch5674/handle-context-cancel branch January 26, 2021 10:56
soundvibe added a commit that referenced this pull request Jan 27, 2021
* master:
  [dtests] Docker tests integration with docker-compose (#3031)
  [dbnode] Comments / remove unused var (#3124)
  [query] Handle context.Canceled and map to 499 http status (#3069)
soundvibe added a commit that referenced this pull request Jan 29, 2021
* master:
  [dbnode] Add aggregate term limit regression test (#3135)
  [DOCS] Adding Prometheus steps to quickstart (#3043)
  [dbnode] Revert AggregateQuery changes (#3133)
  Fix TestSessionFetchIDs flaky test (#3132)
  [dbnode] Alter multi-segments builder to order by size before processing (#3128)
  [dbnode] Emit aggregate usage metrics (#3123)
  [dbnode] Add Shard.OpenStreamingReader method (#3119)
  [dtests] Docker tests integration with docker-compose (#3031)
  [dbnode] Comments / remove unused var (#3124)
  [query] Handle context.Canceled and map to 499 http status (#3069)
  [dbnode] Use StreamingReadMetadata for bootstrapping (#2938)
  [dbnode] Use DefaultTestOptions in test code (#3113)

# Conflicts:
#	src/dbnode/storage/bootstrap/bootstrapper/fs/source.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants