feat: Show active transaction handle count in !admin federation incoming-federation

This commit is contained in:
nexy7574 2026-02-21 16:39:47 +00:00 committed by timedout
parent 9016cd11a6
commit 4657844d46
No known key found for this signature in database
GPG key ID: 0FA334385D0B689F
3 changed files with 14 additions and 2 deletions

View file

@ -30,12 +30,15 @@ pub(super) async fn incoming_federation(&self) -> Result {
.federation_handletime .federation_handletime
.read(); .read();
let mut msg = format!("Handling {} incoming pdus:\n", map.len()); let mut msg = format!(
"Handling {} incoming PDUs across {} active transactions:\n",
map.len(),
self.services.transaction_ids.txn_active_handle_count()
);
for (r, (e, i)) in map.iter() { for (r, (e, i)) in map.iter() {
let elapsed = i.elapsed(); let elapsed = i.elapsed();
writeln!(msg, "{} {}: {}m{}s", r, e, elapsed.as_secs() / 60, elapsed.as_secs() % 60)?; writeln!(msg, "{} {}: {}m{}s", r, e, elapsed.as_secs() / 60, elapsed.as_secs() % 60)?;
} }
msg msg
}; };

View file

@ -158,6 +158,8 @@ async fn process_inbound_transaction(
// value, returning an empty response may lie to the remote and make them // value, returning an empty response may lie to the remote and make them
// think we processed it properly (and lose events), but we also can't return // think we processed it properly (and lose events), but we also can't return
// an actual error. // an actual error.
drop(sender);
services.transaction_ids.finish_federation_txn(&txn_key);
panic!("failed to handle incoming transaction"); panic!("failed to handle incoming transaction");
}; };

View file

@ -52,6 +52,13 @@ impl crate::Service for Service {
} }
impl Service { impl Service {
#[must_use]
pub fn txn_active_handle_count(&self) -> usize {
let state = self.servername_txnid_active.read();
state.len()
}
pub fn add_client_txnid( pub fn add_client_txnid(
&self, &self,
user_id: &UserId, user_id: &UserId,