Locking mechanism

mongodb only implementation.