8000 Fuerte simplify by graetzer · Pull Request #12270 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Fuerte simplify #12270

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

Merged
merged 31 commits into from
Aug 24, 2020
Merged

Fuerte simplify #12270

merged 31 commits into from
Aug 24, 2020

Conversation

graetzer
Copy link
Contributor

Fuerte connections no longer perform reconnects internally which should make it easier to reason about it.

http://jenkins01.arangodb.biz:8080/job/arangodb-matrix-pr/11191/

@graetzer graetzer requested review from jsteemann and neunhoef July 22, 2020 12:32
@graetzer graetzer requested a review from dhly-etc July 22, 2020 12:56
Copy link
Contributor
@dhly-etc dhly-etc left a comment

Choose a reason for hiding this comment

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

I don't feel qualified to give this a proper approval, but other than a few small changes the code stuff looks okay to me. I think the TLA changes need a review from Max or someone.

Comment on lines +404 to +405
// TODO: should we have a better timeout mechanism?
// this->setTimeout(GeneralCommTask<T>::DefaultTimeout);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// TODO: should we have a better timeout mechanism?
// this->setTimeout(GeneralCommTask<T>::DefaultTimeout);

Copy link
Member

Choose a reason for hiding this comment

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

Seconded.

Comment on lines +138 to 140
if (_protocol == "http" || _protocol == "h1") {
config.protocol = fuerte::ProtocolType::Http;
} else if (_protocol == "http2" || _protocol == "h2") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (_protocol == "http" || _protocol == "h1") {
config.protocol = fuerte::ProtocolType::Http;
} else if (_protocol == "http2" || _protocol == "h2") {
if (_protocol == "http2" || _protocol == "h2") {

Copy link
Member

Choose a reason for hiding this comment

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

Seconded.

@jsteemann jsteemann added this to the devel milestone Jul 22, 2020
@graetzer
Copy link
Contributor Author

@graetzer graetzer requested a review from maierlars August 3, 2020 08:51
Copy link
Member
@neunhoef neunhoef left a comment

Choose a reason for hiding this comment

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

Overall: Well done! This is a good simplifaction.

I have committed changes to the model, since it did not fit to the implementation. However, this already was the case before your changes. The model now does shutdownConnection as the implementation does, rather than setting the state to Closed and then calling asyncWriteNextRequest. This now allows to add a few more assertions, which seems sensible. I have commited my suggested changes to the branch feature/fuerte-simplify-suggestion. This also contains some cleanups in comments, some dead code and bad comment removal. Just have a look.

std::chrono::steady_clock::time_point _writeStart;
// This is the time when the latest write operation started.
// We use this to compute the timeout of the corresponding read if the
// write was done.

std::atomic<int> _leased;
Copy link
Member

Choose a reason for hiding this comment

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

I think this was forgotten to remove. It is no longer used.

Copy link
Member

Choose a reason for hiding this comment

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

Done in branch feature/fuerte-simplify-suggestion.

@@ -22,10 +22,10 @@ variables \* VERIFIED

procedure startConnection() { \* VERIFIED
(* This is called whenever the connection broke and we want to immediately
Copy link
Member

Choose a reason for hiding this comment

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

This comment is out of date and should be corrected.

// start connecting only if state is disconnected
Connection::State exp = Connection::State::Created;
if (_state.compare_exchange_strong(exp, Connection::State::Connecting)) {
FUERTE_LOG_DEBUG << "startConnection: this=" << this << "\n";
Copy link
Member

Choose a reason for hiding this comment

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

The model suggests that we can add an assertion on _active here. We should at least try this, if it breaks the tests, then we have a discrepancy between the model and the implementation.

Copy link
Member

Choose a reason for hiding this comment

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

Done in branch feature/fuerte-simplify-suggestion.

@@ -485,46 +341,19 @@ void H1Connection<ST>::asyncWriteCallback(asio_ns::error_code const& ec,
FUERTE_ASSERT(this->_state != Connection::State::Connecting);
Copy link
Member

Choose a reason for hiding this comment

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

The comment above is outdated: The state is now called Closed and it can happen for TCP or for TLS connections. Please correct.

Copy link
Member

Choose a reason for hiding this comment

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

Changed in branch feature/fuerte-simplify-suggestion

@@ -485,46 +341,19 @@ void H1Connection<ST>::asyncWriteCallback(asio_ns::error_code const& ec,
FUERTE_ASSERT(this->_state != Connection::State::Connecting);
Copy link
Member
F438

Choose a reason for hiding this comment

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

The model suggests that state Created cannot happen here. Let's adjust the code to this.

Copy link
Member

Choose a reason for hiding this comment

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

Done in branch feature/fuerte-simplify-suggestion.

<< static_cast<int>(state)
<< " instead of the expected 'Connected'\n";
}
state == Connection::State::Closed);
Copy link
Member

Choose a reason for hiding this comment

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

This can actually now be changed to only Connected, since we no longer call asyncWriteNextRequest when the connection is closed. See model.

Copy link
Member

Choose a reason for hiding this comment

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

Done in branch feature/fuerte-simplify-suggestion.

void H2Connection<T>::terminateActivity() {
// TODO: fill in the necessary stuff to fix bugs in this class
}
//template <SocketType T>
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove that dead code. Done in branch feature/fuerte-simplify-suggestion.

Comment on lines +404 to +405
// TODO: should we have a better timeout mechanism?
// this->setTimeout(GeneralCommTask<T>::DefaultTimeout);
Copy link
Member

Choose a reason for hiding this comment

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

Seconded.

RequestOptions const& options, Headers headers) {
RequestOptions const& options, Headers headers,
std::chrono::duration<double> timeout) {
TRI_ASSERT(path.find("/_db/") == std::string::npos);
Copy link
Member

Choose a reason for hiding this comment

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

This looks dangerous to me. Why would this never show up in an path of a URL? Granted, it is only an assertion and so it would only impact us in the tests, but still. I would like to understand the rationale behind this.

Copy link
Member

Choose a reason for hiding this comment

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

OK, I think I understand, one is supposed to use the database option. Maybe only assert that the path does not begin with /_db/?

Comment on lines +138 to 140
if (_protocol == "http" || _protocol == "h1") {
config.protocol = fuerte::ProtocolType::Http;
} else if (_protocol == "http2" || _protocol == "h2") {
Copy link
Member

Choose a reason for hiding this comment

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

Seconded.

Copy link
Contributor
@maierlars maierlars left a comment

Choose a reason for hiding this comment

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

Models vs Code of *Connection LGTM

@jsteemann
Copy link
Contributor

@jsteemann jsteemann merged commit 39eb2e5 into devel Aug 24, 2020
@jsteemann jsteemann deleted the feature/fuerte-simplify branch August 24, 2020 13:19
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.

5 participants
0