Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel push rule deletes causing deadlock on main process #16053

Open
matrixbot opened this issue Dec 21, 2023 · 1 comment
Open

Parallel push rule deletes causing deadlock on main process #16053

matrixbot opened this issue Dec 21, 2023 · 1 comment

Comments

@matrixbot
Copy link
Collaborator

matrixbot commented Dec 21, 2023

This issue has been migrated from #16053.


Yesterday our main process locked up after receiving a few parallel deletes to the same push rule:

{
    "exc_type": "DeadlockDetected",
    "exc_value": "deadlock detected\nDETAIL:  Process 13307 waits for ShareLock on transaction 2644686651; blocked by process 13320.\nProcess 13320 waits for ShareLock on transaction 2644691260; blocked by process 13307.\nHINT:  See server log for query details.\nCONTEXT:  while deleting tuple (38048,43) in relation \"push_rules\"\n",
    "level": "error",
    "method": "DELETE",
    "url": "/_matrix/client/v3/pushrules/global/room/!QE9hkmS...",
}

I had a quick look and there doesn't appear to be any linearization of push rule requests allowing for this to happen in rare cases. Quick fix is probably just linearize all push rule requests by user ID, the volume should be sufficiently low to not cause issues. PR for this: matrix-org/synapse#16052

I also spotted two explicit locks on the entire push rules table that may be causing issues: https://github.com/matrix-org/synapse/blob/01a45869f034265b9757992aa1a5eb7a0923351c/synapse/storage/databases/main/push_rule.py#L399-L401

I don't think this are required (anymore, at least) since the select & upsert are already part of a transaction, PR for this:matrix-org/synapse#16051

@matrixbot matrixbot changed the title Dummy issue Parallel push rule deletes causing deadlock on main process Dec 22, 2023
@matrixbot matrixbot reopened this Dec 22, 2023
@Fizzadar
Copy link
Contributor

This can be closed! The PRs were merged I just forgot to close out the original issue: matrix-org/synapse#16053

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants