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

Fix oldest_pdu_in_federation_staging #10455

Merged
merged 2 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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