diff --git a/src/api/client_server/keys.rs b/src/api/client_server/keys.rs index c4422079..c8523117 100644 --- a/src/api/client_server/keys.rs +++ b/src/api/client_server/keys.rs @@ -1,6 +1,6 @@ use std::{ - collections::{hash_map, BTreeMap, HashMap, HashSet}, - time::{Duration, Instant}, + collections::{BTreeMap, HashMap, HashSet}, + time::Duration, }; use futures_util::{stream::FuturesUnordered, StreamExt}; @@ -385,47 +385,9 @@ pub(crate) async fn get_keys_helper bool>( let mut failures = BTreeMap::new(); - let back_off = |id| async { - match services().globals.bad_query_ratelimiter.write().await.entry(id) { - hash_map::Entry::Vacant(e) => { - e.insert((Instant::now(), 1)); - } - hash_map::Entry::Occupied(mut e) => { - *e.get_mut() = (Instant::now(), e.get().1 + 1); - } - } - }; - let mut futures: FuturesUnordered<_> = get_over_federation .into_iter() .map(|(server, vec)| async move { - if let Some((time, tries)) = services() - .globals - .bad_query_ratelimiter - .read() - .await - .get(server) - { - // Exponential backoff - let mut min_elapsed_duration = - Duration::from_secs(30) * (*tries) * (*tries); - if min_elapsed_duration > Duration::from_secs(60 * 60 * 24) { - min_elapsed_duration = Duration::from_secs(60 * 60 * 24); - } - - if let Some(remaining) = - min_elapsed_duration.checked_sub(time.elapsed()) - { - debug!(%server, %tries, ?remaining, "Backing off from server"); - return ( - server, - Err(Error::BadServerResponse( - "bad query, still backing off", - )), - ); - } - } - let mut device_keys_input_fed = BTreeMap::new(); for (user_id, keys) in vec { device_keys_input_fed.insert(user_id.to_owned(), keys.clone()); @@ -454,7 +416,6 @@ pub(crate) async fn get_keys_helper bool>( let response = match response { Ok(response) => response, Err(error) => { - back_off(server.to_owned()).await; debug!(%server, %error, "remote device key query failed"); failures.insert(server.to_string(), json!({})); continue; diff --git a/src/service/globals.rs b/src/service/globals.rs index 0881ce13..c7aa7078 100644 --- a/src/service/globals.rs +++ b/src/service/globals.rs @@ -84,8 +84,6 @@ pub(crate) struct Service { Arc>>, pub(crate) bad_signature_ratelimiter: Arc, RateLimitState>>>, - pub(crate) bad_query_ratelimiter: - Arc>>, pub(crate) servername_ratelimiter: OnDemandHashMap, pub(crate) roomid_mutex_insert: TokenSet, @@ -278,7 +276,6 @@ impl Service { admin_bot_room_alias_id, bad_event_ratelimiter: Arc::new(RwLock::new(HashMap::new())), bad_signature_ratelimiter: Arc::new(RwLock::new(HashMap::new())), - bad_query_ratelimiter: Arc::new(RwLock::new(HashMap::new())), servername_ratelimiter: OnDemandHashMap::new( "servername_ratelimiter".to_owned(), ),