Inline deadlockGuardedWait and change the WaitElement add to only happen once, as it could lead to leftover waits that never got notified, leading to a dead database.
Merge pull request #2864 from rickardoberg/communitylockleak19

Community LockManager lock leak fix