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

Consume/drain the inbound in case a cancellation is received before subscription #13493

Conversation

kushagraThapar
Copy link
Member

@kushagraThapar kushagraThapar commented Jul 24, 2020


private boolean mayHaveBody(HttpMethod method) {
int code = this.statusCode();
return !((code >= 100 && code < 200) || code == 204 || code == 205 ||
Copy link
Member

Choose a reason for hiding this comment

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

Do 304 classified as non body status code ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, 304 will be a non body status code

Copy link
Member

Choose a reason for hiding this comment

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

So lets add that here

* reading was delayed for some reason.
*/
private void releaseAfterCancel(HttpMethod method) {
if (mayHaveBody(method) && this.state.compareAndSet(ReactorNettyResponseState.NOT_SUBSCRIBED, ReactorNettyResponseState.CANCELLED)) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need mayHaveBody check , what happen if we clear on all cancel irrespective of body, we can avoid extra check ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since we are draining content here, we want to make sure we drain it under very specific conditions, specially when the body can be present.

Copy link
Member

Choose a reason for hiding this comment

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

That is fine ,but my doubt is if some valid response miss mayHaveBody (due to any missed scenario), then we will still face issue , vs draining non body too along with body response (Its a trade off thing )

private boolean mayHaveBody(HttpMethod method) {
int code = this.statusCode();
return !((code >= 100 && code < 200) || code == 204 || code == 205 ||
method.equals(HttpMethod.HEAD) || headers().getContentLength() == 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think some of 4xx error codes from Cosmos (e.g., 400 query plan) also have body.

Copy link
Member Author

Choose a reason for hiding this comment

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

Would these be considered as error or success ?

Copy link
Member

Choose a reason for hiding this comment

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

this condition is already returning true for 4xx, isn't ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it is.

Copy link
Contributor

@moderakh moderakh left a comment

Choose a reason for hiding this comment

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

It is worth if you do a perf test with this change when client is configured in GW mode.

@kushagraThapar
Copy link
Member Author

/check-enforcer override

@kushagraThapar
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kushagraThapar
Copy link
Member Author

kushagraThapar commented Jul 24, 2020

@moderakh - I did a quick perf round for Read Latency and Query Clause In Parallel - and the results look similar to master branch.

improve_reactor_netty_cancellation.txt

@kushagraThapar
Copy link
Member Author

Ran ReadFeedDocumentTests#readDocuments() locally and it passes on this PR - fails on CI - created this issue : #13528

@kushagraThapar
Copy link
Member Author

ConsistencyTests2#validateSessionTokenAsync() consistently fails on CI - passes on local - created this issue - #13529

@kushagraThapar
Copy link
Member Author

Ran WorkflowTests locally and it passes - filed an issue to fix it on the CI - #13531

@kushagraThapar
Copy link
Member Author

Ran UniqueIndexTests locally and it passes - fails on the CI - created a github issue - #13532

@kushagraThapar
Copy link
Member Author

Ran GatewayAddressCache tests locally and it passes - fails on the CI - created github issue : #13533

@kushagraThapar
Copy link
Member Author

/check-enforcer override

@kushagraThapar
Copy link
Member Author

/check-enforcer reset

@simplynaveen20
Copy link
Member

/check-enforcer override

@kushagraThapar kushagraThapar merged commit e7f151b into Azure:master Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reactor Netty intermittently throws IllegalStateException: Only one connection receive subscriber is allowed
3 participants