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

synapse_forward_extremities metric appears to have no rooms in it for periods of time #8792

Closed
benbz opened this issue Nov 21, 2020 · 6 comments · Fixed by #8926
Closed

synapse_forward_extremities metric appears to have no rooms in it for periods of time #8792

benbz opened this issue Nov 21, 2020 · 6 comments · Fixed by #8926
Assignees
Labels
z-bug (Deprecated Label) z-p2 (Deprecated Label)

Comments

@benbz
Copy link
Contributor

benbz commented Nov 21, 2020

image

So it appears like Synapse is reporting there are 0 rooms with <= Infinity Forward Extremities. This appears to happen semi-regularly

@clokep
Copy link
Member

clokep commented Nov 23, 2020

That's a bit odd, is this new behavior or has it been going on for a while?

Note that this value is only updated every 60 minutes (updated by the read_forward_extremities background task), so that's why it seems to oscillate between the two values.

@benbz
Copy link
Contributor Author

benbz commented Nov 23, 2020

The graphs I have access to only go back 30 days. I believe I can see this behaviour going on for the whole of that period, but it is difficult to tell

@anoadragon453
Copy link
Member

Assuming this isn't due to performance or configuration changes, the only way I could see this being possible is if the query for this metric returning zero rows:

@wrap_as_background_process("read_forward_extremities")
async def _read_forward_extremities(self):
def fetch(txn):
txn.execute(
"""
SELECT t1.c, t2.c
FROM (
SELECT room_id, COUNT(*) c FROM event_forward_extremities
GROUP BY room_id
) t1 LEFT JOIN (
SELECT room_id, COUNT(*) c FROM current_state_events
GROUP BY room_id
) t2 ON t1.room_id = t2.room_id
"""
)
return txn.fetchall()
res = await self.db_pool.runInteraction("read_forward_extremities", fetch)
_extremities_collecter.update_data(x[0] for x in res)
_excess_state_events_collecter.update_data(
(x[0] - 1) * x[1] for x in res if x[1]
)

Handing [] to _extremities_collecter.update_data will clear all values.

@benbz is the synapse_excess_extremity_events bucket showing similar behaviour btw?

@benbz
Copy link
Contributor Author

benbz commented Nov 27, 2020

synapse_excess_extremity_events does seem to exhibit the same behaviour.

One thing I will say is that all the examples I saw in the last 48 hours seem to correspond to a server restart. And metrics only start being non-zero an hour later. I can't confirm/deny whether the historical ones all relate to a server restart

@anoadragon453
Copy link
Member

anoadragon453 commented Nov 27, 2020

Aha! Well that bucket won't be updated until at least 1 hour has passed since the server has started up, so on any scrape in the meantine we'd see 0's.

One solution is to just call the function immediately, and then again every 1hr. Looks like we actually do this already for some metrics:

if hs.config.limit_usage_by_mau or hs.config.mau_stats_only:
generate_monthly_active_users()
clock.looping_call(generate_monthly_active_users, 5 * 60 * 1000)

@richvdh
Copy link
Member

richvdh commented Nov 27, 2020

One solution is to just call the function immediately, and then again every 1hr.

It might be a bit annoying to have to call that relatively expensive query during startup. can we instead just not emit the metric until the query has run?

@richvdh richvdh changed the title synapse_forward_extremities appears to have no rooms in it for periods of time synapse_forward_extremities metric appears to have no rooms in it for periods of time Dec 10, 2020
@clokep clokep added z-bug (Deprecated Label) z-p2 (Deprecated Label) and removed info-needed labels Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
z-bug (Deprecated Label) z-p2 (Deprecated Label)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants