Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix oldest_pdu_in_federation_staging (#10455)
Browse files Browse the repository at this point in the history
If the staging area was empty we'd report an age of 51 years, which is
not true or helpful.
  • Loading branch information
erikjohnston authored Jul 27, 2021
1 parent 076dead commit 5b22d5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/10455.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `synapse_federation_server_oldest_inbound_pdu_in_staging` Prometheus metric to not report a max age of 51 years when the queue is empty.
7 changes: 5 additions & 2 deletions synapse/storage/databases/main/event_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,12 +1227,15 @@ def _get_stats_for_federation_staging_txn(txn):
(count,) = txn.fetchone()

txn.execute(
"SELECT coalesce(min(received_ts), 0) FROM federation_inbound_events_staging"
"SELECT min(received_ts) FROM federation_inbound_events_staging"
)

(received_ts,) = txn.fetchone()

age = self._clock.time_msec() - received_ts
# If there is nothing in the staging area default it to 0.
age = 0
if received_ts is not None:
age = self._clock.time_msec() - received_ts

return count, age

Expand Down

0 comments on commit 5b22d5e

Please sign in to comment.