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

Parallel push rule deletes causing deadlock on main process #16053

Open
Fizzadar opened this issue Aug 2, 2023 · 0 comments
Open

Parallel push rule deletes causing deadlock on main process #16053

Fizzadar opened this issue Aug 2, 2023 · 0 comments
Labels
O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Major Major functionality / product severely impaired, no satisfactory workaround. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@Fizzadar
Copy link
Contributor

Fizzadar commented Aug 2, 2023

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: #16052

I also spotted two explicit locks on the entire push rules table that may be causing issues:

# Lock the table since otherwise we'll have annoying races between the
# SELECT here and the UPSERT below.
self.database_engine.lock_table(txn, "push_rules")

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

@erikjohnston erikjohnston added T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. S-Major Major functionality / product severely impaired, no satisfactory workaround. O-Uncommon Most users are unlikely to come across this or unexpected workflow labels Aug 9, 2023
erikjohnston pushed a commit that referenced this issue Aug 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Major Major functionality / product severely impaired, no satisfactory workaround. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

No branches or pull requests

2 participants