There following issues here:
- Whenever Galera BF (brute force) transaction decides to abort conflicting transaction it will kill that thread using thd::awake()
- Whenever replication selects a thread as a victim it will call thd::awake()
- User KILL [QUERY|CONNECTION] ... for a thread it will also call thd::awake()
Whenever one of these actions is executed we will hold number of InnoDB internal mutexes and thd mutexes.
Sometimes these mutexes are taken in different order causing mutex deadlock (see one detailed case below).