-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: Add a new cluster state "Unhealthy" #63
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feature overall lgtm, just a few questions and comments.
CHANGELOG.md
Outdated
`Unhealthy` clusters won't get any new queries, if all queries are unhealthy queries are queued. | ||
<br>Note: Use the now configurable scaler reconcile interval to detect cluster changes quickly ([#63]). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: I don't quite understand the sentence in line 15. It is either wrong, or worded weirdly.
note: markdownlint complains about the <br />
tag. I think we should remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, there was a typo: a9726af
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL a backslash also works: 5e5b022
#[instrument(skip(self, cluster), fields(cluster_name = cluster.name))] | ||
async fn process_cluster(&self, cluster: &TrinoClusterConfig, state: ClusterState) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: You should add a small doc comment explaining what this method does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 373ab07
if let Err(err) = self | ||
.persistence | ||
.set_cluster_query_count(&cluster.name, 0) | ||
.await |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Why exactly do we set the number of queries to zero here? Can you add a developer comment here which shortly explains it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some rustdoc in 373ab07 explaining it. Is that sufficient in this case here?
ClusterState::Ready | ClusterState::Draining{ .. } => Some(cluster), | ||
}) | ||
.map(|cluster| self.process_cluster(cluster)), | ||
.map(|(cluster, state)| self.process_cluster(cluster, state)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: It seems like we are not actually mapping anything here. Does it maybe make more sense to use .for_each()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, as we are using https://docs.rs/futures/latest/futures/future/fn.join_all.html here
Checking trino-lb v0.3.2 (/home/sbernauer/stackable/trino-lb/trino-lb)
error[E0308]: mismatched types
--> trino-lb/src/maintenance/query_count_fetcher.rs:139:54
|
139 | .for_each(|(cluster, state)| self.process_cluster(cluster, state))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found future
|
note: calling an async function returns a future
--> trino-lb/src/maintenance/query_count_fetcher.rs:139:54
|
139 | .for_each(|(cluster, state)| self.process_cluster(cluster, state))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider `await`ing on the `Future`
|
139 | .for_each(|(cluster, state)| self.process_cluster(cluster, state).await)
| ++++++
help: consider using a semicolon here
|
139 | .for_each(|(cluster, state)| { self.process_cluster(cluster, state); })
| + +++
error[E0277]: `()` is not an iterator
--> trino-lb/src/maintenance/query_count_fetcher.rs:135:30
|
135 | let result = join_all(
| ______________________________^
136 | | self.clusters
137 | | .iter()
138 | | .zip(cluster_states)
139 | | .for_each(|(cluster, state)| self.process_cluster(cluster, state))
140 | | )
| |_________________^ `()` is not an iterator
|
= help: the trait `Iterator` is not implemented for `()`
= note: required for `()` to implement `IntoIterator`
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `trino-lb` (bin "trino-lb") due to 2 previous errors
We could do some things around futures::stream::iter(self.clusters.iter().zip(cluster_states)).for_each_concurrent(1000000, |(cluster, state)| self.process_cluster(cluster, state)).await
, but
a.) that a different approach than we take everywhere else.
b.) The result.len()
breaks, we need to do it differently
Not sure if that's worth it
Part of #58
WIP, it still has commits from #62 until that is merged