diff --git a/book/changelog.md b/book/changelog.md index 3cd11429..369a850f 100644 --- a/book/changelog.md +++ b/book/changelog.md @@ -205,6 +205,10 @@ This will be the first release of Grapevine since it was forked from Conduit 21. Fix tiebreaking comparisons between events during state resolution. This will reduce the rate at which servers disagree about the state of rooms. ([!141](https://gitlab.computer.surgery/matrix/grapevine/-/merge_requests/141)) +22. Fix bug where the backoff state for remote device key queries was not reset + after a successful request, causing an increasing rate of key query failures + over time until a server restart. + ([!149](https://gitlab.computer.surgery/matrix/grapevine/-/merge_requests/149)) ### Added diff --git a/src/api/client_server/keys.rs b/src/api/client_server/keys.rs index 40a2ccb7..3b5603c9 100644 --- a/src/api/client_server/keys.rs +++ b/src/api/client_server/keys.rs @@ -486,6 +486,11 @@ async fn back_off_key_requests(server: OwnedServerName) { } } +/// Stops backing off remote device key requests to a server after a success. +async fn reset_key_request_back_off(server: &ServerName) { + services().globals.bad_query_ratelimiter.write().await.remove(server); +} + /// Requests device keys from a remote server, unless the server is in backoff. /// /// Updates backoff state depending on the result of the request. @@ -494,9 +499,12 @@ async fn request_keys_from( keys: Vec<(&UserId, &Vec)>, ) -> Result { let result = request_keys_from_inner(server, keys).await; - if let Err(error) = &result { - debug!(%server, %error, "remote device key query failed"); - back_off_key_requests(server.to_owned()).await; + match &result { + Ok(_) => reset_key_request_back_off(server).await, + Err(error) => { + debug!(%server, %error, "remote device key query failed"); + back_off_key_requests(server.to_owned()).await; + } } result }