e5f92947e7
I've been debugging a cause of flakey complement-crypto tests for about a month now. I was pretty convinced it was deadlocking somewhere in the memory store `save_changes` code. With additional logging, it's now clear that the there is an ABBA style deadlock when `save_changes` is called at the same time as `get_state_events`. I've also adjusted code for `get_user_ids` as it has a very similar pattern and also acquires locks in reverse order to `save_changes`, so is potentially vulnerable to this.