Skip to content

Commit cd1e772

Browse files
committed
api: retry conflicts as a workaround
This is a workaround for comment creation / updates conflicting with the `loom` service that indexes threads objects concurrently. We will be fixing this properly in the backend, but as a workaround we will retry conflicts for now.
1 parent 1ebc746 commit cd1e772

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

api/src/retry.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Retrier {
6060
}
6161

6262
match send_request() {
63-
Ok(response) if response.status().is_server_error() => {
63+
Ok(response) if should_retry(response) => {
6464
warn_and_sleep!(format!("{} for {}", response.status(), response.url()))
6565
}
6666
Err(error) if error.is_timeout() => warn_and_sleep!(error),
@@ -74,6 +74,11 @@ impl Retrier {
7474
}
7575
}
7676

77+
fn should_retry(response: &Response) -> bool {
78+
// TODO(mcobzarenco): we retry conflicts because these can be generated by `loom`
79+
response.status().is_server_error() || response.status() == StatusCode::CONFLICT
80+
}
81+
7782
#[cfg(test)]
7883
mod tests {
7984
use super::{Retrier, RetryConfig, RetryStrategy};

0 commit comments

Comments
 (0)