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

Fix a connection reuse race #191

Merged
merged 1 commit into from
Nov 24, 2024
Merged

Conversation

patrickbkr
Copy link
Member

@patrickbkr patrickbkr commented Jan 27, 2024

HTTP1.1 connection reuse is subject to a race condition where remote connection tear down races with reusing the connection for a new request. This change wires HTTP1.1 into the same request retry mechanism HTTP2 uses.

HTTP2 was subject to the same race. I updated the PR respectively.

@patrickbkr patrickbkr changed the title Implement retrying for HTTP1.1 as well Fix a connection reuse race Jan 28, 2024
Connection reuse is subject to a race condition where remote connection
tear down races with reusing the connection for a new request. There were
already locks in place for access to `$!next-response-vow` /
`%!outstanding-stream-responses` but the lock didn't cover the check for
`$!dead`, thus it was possible for the dead check to succeed, the
connection being torn down and only then the next response vow to be taken.
$!next-response-vow = $next-response-promise.vow;
}
}
return Promise.broken(PipelineClosedBeforeHeaders.new) if $broken;

Choose a reason for hiding this comment

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

Maybe this line would be better in the if $!dead arm and no need for var $broken

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 would be better. But see the comment. ;-)

Copy link
Member Author

Choose a reason for hiding this comment

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

To elaborate a bit more, the PR referenced in the comment actually has been merged. But I don't intentionally want to break Cro for Rakudo versions <= 2024.05 yet.

Choose a reason for hiding this comment

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

oh - yes I see the comment is related - missed that!

}
return Promise.broken(PipelineClosedBeforeHeaders.new) if $broken;

Choose a reason for hiding this comment

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

ditto

Copy link
Member Author

Choose a reason for hiding this comment

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

Same as above.

Copy link

@librasteve librasteve left a comment

Choose a reason for hiding this comment

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

I have reviewed for code quality and ensured that there is no malicious code

My experience with concurrency is limited - so I am not able to confirm that eg. any source of deadlock with other interacting code has been identified

So this review is caveat that tests over a range of asynchronous situations have been performed.

@patrickbkr patrickbkr merged commit ac03da8 into croservices:master Nov 24, 2024
2 checks passed
@patrickbkr patrickbkr deleted the http11-retry branch November 24, 2024 22:32
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.

2 participants