Add database locking.