You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Large amounts of repeated DB queries when using multiple federation sender workers #9113
wake_destinations_needing_catchup performs massive amounts of repeated SELECT queries when using multiple federation_sender workers. Using a single federation_sender works well.
Here are the debug logs from the federation senders, from startup up until the issue starts occuring. I don't think there's any value to providing more of the log, as the output just repeats itself after this point.
The actual destination in the query seems to vary though, I've seen three destinations so far: toofat.ru, wc20.tencapsule.com and fpoe.info. The output of a sample query with all three destinations follows below:
synapse_prod=# SELECT destination FROM destinations WHERE destination IN ( SELECT destination FROM destination_rooms WHERE destination_rooms.stream_ordering > destinations.last_successful_stream_ordering ) AND destination > 'toofat.ru' AND ( retry_last_ts IS NULL OR retry_last_ts + retry_interval < 1610625475512 ) ORDER BY destination LIMIT 25;
destination
-------------
wolffy.eu
(1 row)
synapse_prod=# SELECT destination FROM destinations WHERE destination IN ( SELECT destination FROM destination_rooms WHERE destination_rooms.stream_ordering > destinations.last_successful_stream_ordering ) AND destination > 'fpoe.info' AND ( retry_last_ts IS NULL OR retry_last_ts + retry_interval < 1610625676424 ) ORDER BY destination LIMIT 25;
destination
---------------------
komputernerds.com
matrix.insw.cz
matrix.noppesict.nl
supersandro.de
thedreamer.nl
toofat.ru
wolffy.eu
(7 rows)
synapse_prod=# SELECT destination FROM destinations WHERE destination IN ( SELECT destination FROM destination_rooms WHERE destination_rooms.stream_ordering > destinations.last_successful_stream_ordering ) AND destination > 'wc20.tencapsule.com' AND ( retry_last_ts IS NULL OR retry_last_ts + retry_interval < 1610631393252 ) ORDER BY destination LIMIT 25;
destination
-------------
wolffy.eu
(1 row)
Steps to reproduce
Enable two or more federation_sender workers
Start the main process and all workers
Wait ~30 seconds
Of course, this is probably specific to me and the contents of my db, so naturally I'll provide any further information as needed. Just let me know! :)
Version information
Homeserver: queersin.space
If not matrix.org:
Version: 1.25 (note: problem occurred on 1.24 as well)
Oh, right. This is it just iterating through all the destinations that need to be retried, but since there are multiple federation senders we rapidly chew through the list until we hit destinations we need to retry (I believe).
We may want to at some point clear out entries from the list that are e.g. more than a month old, to stop the list just ever increasing.
Just to clarify how much of this stuff is going, I should add that the wake_destinations_needing_catchup job on each federation sender jumps to 100% DB use in the "DB usage by background jobs (including scheduling time)" metric.
Yeah, we're seeing this on matrix.org as well. I'm hoping that changing the query means that it goes fast enough that we don't care too much that there are so many of them, but we'll see.
Oh, I should've been clearer at the start - it keeps going indefinitely. The three destinations I mentioned in the original issue are the ones I found repeated queries for. I only noticed it yesterday morning after it had been going throughout the night. Sorry, it's my first time opening an issue.
Activity
clokep commentedon Jan 14, 2021
Looks like we just noticed this as well -- it should be fixed by #9114.
richvdh commentedon Jan 15, 2021
the link seems to be broken?
why would the problem in #9114 cause lots of repeated queries (as opposed to a small number of very slow ones)?
chgrv commentedon Jan 15, 2021
Sorry, I deleted the logs when the issue was closed, in case there was any sensitive info in there I missed. It's back up now.
richvdh commentedon Jan 15, 2021
Thanks.
TL;DR, there is a lot of this stuff going on:
Again I'm not sure that's consistent with #9114 so I'm going to reopen this.
[edited, sorry I copied the wrong bit of log initially!]
erikjohnston commentedon Jan 15, 2021
Oh, right. This is it just iterating through all the destinations that need to be retried, but since there are multiple federation senders we rapidly chew through the list until we hit destinations we need to retry (I believe).
We may want to at some point clear out entries from the list that are e.g. more than a month old, to stop the list just ever increasing.
chgrv commentedon Jan 15, 2021
Just to clarify how much of this stuff is going, I should add that the
wake_destinations_needing_catchupjob on each federation sender jumps to 100% DB use in the "DB usage by background jobs (including scheduling time)" metric.erikjohnston commentedon Jan 15, 2021
Yeah, we're seeing this on matrix.org as well. I'm hoping that changing the query means that it goes fast enough that we don't care too much that there are so many of them, but we'll see.
chgrv commentedon Jan 15, 2021
Oh, I should've been clearer at the start - it keeps going indefinitely. The three destinations I mentioned in the original issue are the ones I found repeated queries for. I only noticed it yesterday morning after it had been going throughout the night. Sorry, it's my first time opening an issue.
chgrv commentedon Jan 28, 2021
Hi, just wanted to confirm that this was not related to #9114, and persists after upgrading to 1.26.0.
clokep commentedon Jan 28, 2021
#9198 might help this a bit too, although the cause seems a bit different? (Note that that will be in 1.27.0 and requires using workers via Redis).
chgrv commentedon Feb 19, 2021
This appears to be fixed in 1.27. Thanks a bunch for all your hard work! 😄