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

Run PREPARE on all nodes (Issue #106) #115

Merged
merged 3 commits into from
Dec 4, 2020

Conversation

havaker
Copy link
Contributor

@havaker havaker commented Nov 21, 2020

This pull request implements #106 by sending PREPARE via all available connections.

@havaker
Copy link
Contributor Author

havaker commented Nov 23, 2020

@piodul @psarna please review

let mut results = try_join_all(handles).await?;

// Check if every received statement has the same ID
for p in results.windows(2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this additional check to a separate helper function (called validate_prepare_ids or something alike).
Also, consider writing it in a more declarative fashion, e.g.:

results.windows(2).all(|p| p[0].get_id() == p[1].get_id()) // + add error handling at the end of the chain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

)),
_ => Err(anyhow!("Unexpected frame received")),
let connections = self.get_connections()?;
let all_connections = connections.iter().map(|(_, v)| v).flatten();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use flat_map:

let all_connections = connections.iter().flat_map(|(_, v)| v);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@piodul
Copy link
Collaborator

piodul commented Dec 4, 2020

@havaker There were two big PRs merged which caused this PR to have conflicts with the main branch - please rebase.

@havaker
Copy link
Contributor Author

havaker commented Dec 4, 2020

@havaker There were two big PRs merged which caused this PR to have conflicts with the main branch - please rebase.

Done

Copy link
Collaborator

@piodul piodul left a comment

Choose a reason for hiding this comment

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

Left one small nit, otherwise LGTM

Comment on lines 197 to 200
match results.pop() {
Some(result) => Ok(result),
None => Err(TransportError::NoConnectionsAvailable),
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Convert it to:

results.pop().ok_or_else(TransportError::NoConnectionsAvailable)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (I chose to use ok_or instead of ok_or_else)

@piodul piodul merged commit 5ab219b into scylladb:main Dec 4, 2020
@piodul piodul mentioned this pull request Dec 4, 2020
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.

None yet

3 participants