-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Very slow deletes from device_inbox
during /sync
requests
#16479
Comments
an
Apparently the query optimiser isn't smart enough to know that it would do better searching for each of the 100 |
This code changed recently in #16240 and again in #16312. A couple of thoughts:
|
Sadness...
something along that?
🤦 Indeed, I just didn't think about it. |
The query planner woes sounds similar to matrix-org/sliding-sync@fa67467 except in that case we wanted a seq scan. |
Yes. Except you need an And I don't think you need |
Someone can create a device with the same ID, and without the check it would then delete the messages aimed at the new device. |
well, that would be a stupid thing to do :) But fair enough. Stick a comment in, though - that's quite subtle! |
I don't get the same plan with my deploy on pg15:
With #16492 , I get:
So it's probably a tad slower on more modern PG, but at least we will (?) not get a seqscan on older ones. @richvdh could you do a comparison with your test DB to check the new query is ok on PG11? Also note that my new query delete 10 rows and not 12, I need to check why. |
The indicated rows is the number of lines for the plan and not the number of deleted records 😭 . I have executed the 2 inner |
I think this was fixed by #16491? |
#16491 will only have fixed half the problem. To-device message deletions happen in two places: 1) after they are successfully sent to the target device via #16491 changes the |
oh, in fairness, the subject of this issue is just about the For completeness, the device-deletion side looks to be covered in #16492. |
Description
Synchrotron workers are maxing out db connections, resulting in multi-minute scheduling time:
Inspection shows that these are operations of the shape
Some queries have
LIMIT 1000
rather thanLIMIT 100
.Steps to reproduce
device_inbox
/sync
Homeserver
EMS host
Synapse Version
1.94.0
Installation Method
Docker (matrixdotorg/synapse)
Database
postgres 11
Workers
Multiple workers
Platform
k8s
Configuration
No response
Relevant log output
Anything else that would be useful to know?
No response
The text was updated successfully, but these errors were encountered: