implement multi and single process database lock.