This locking code needs to be done at the top of any public method. It's what prevents simultaneous metadata operations from stepping on each other.