Fix deadlocking issues on concurrent writes to the same keys.