Add missing locks to tests to satisfy lock requirements (such as
EXCLUSIVE_LOCKS_REQUIRED(...) (Clang Thread Safety Analysis),
AssertLockHeld(...) and implicit lock assumptions).
This doesn't clear all the thread sanitizer issues, so running with the
tsan enabled still output a lot of errors.
Backport of core PR11623