Avoid deadlock caused by having two connection locks