rename cancel -> cancel_new_retries

This commit is contained in:
Dmitrii Kovalkov
2025-07-29 12:11:47 +04:00
parent e48ac9ed76
commit c53b4545c8
3 changed files with 11 additions and 8 deletions

View File

@@ -351,7 +351,7 @@ impl Node {
warn_threshold: u32,
max_retries: u32,
timeout: Duration,
cancel: &CancellationToken,
cancel_new_retries: &CancellationToken,
) -> Option<mgmt_api::Result<T>>
where
O: FnMut(PageserverClient) -> F,
@@ -402,7 +402,7 @@ impl Node {
self.id,
self.base_url(),
),
cancel,
cancel_new_retries,
)
.await
}

View File

@@ -110,7 +110,7 @@ impl Safekeeper {
warn_threshold: u32,
max_retries: u32,
timeout: Duration,
cancel: &CancellationToken,
cancel_new_retries: &CancellationToken,
) -> mgmt_api::Result<T>
where
O: FnMut(SafekeeperClient) -> F,
@@ -161,7 +161,7 @@ impl Safekeeper {
self.id,
self.base_url(),
),
cancel,
cancel_new_retries,
)
.await
.unwrap_or(Err(mgmt_api::Error::Cancelled))

View File

@@ -149,14 +149,14 @@ impl Service {
.map(SecretString::from);
let mut joinset = JoinSet::new();
let cancel = CancellationToken::new();
let cancel_new_retries = CancellationToken::new();
for (idx, sk) in safekeepers.iter().enumerate() {
let sk = sk.clone();
let http_client = self.http_client.clone();
let jwt = jwt.clone();
let op = op.clone();
let cancel = cancel.clone();
let cancel_new_retries = cancel_new_retries.clone();
joinset.spawn(async move {
let res = sk
.with_client_retries(
@@ -168,7 +168,7 @@ impl Service {
// TODO(diko): This is a wrong timeout.
// It should be scaled to the retry count.
timeout,
&cancel,
&cancel_new_retries,
)
.await;
(idx, res)
@@ -211,7 +211,10 @@ impl Service {
if res.is_ok() {
success_count += 1;
if desired_success_count == Some(success_count) {
cancel.cancel();
// We reached the desired number of successful responses, cancel new retries for
// the remaining safekeepers.
// It does not cancel already started requests, we will still wait for them.
cancel_new_retries.cancel();
}
}
results[idx] = res;