Add lock to _put_and_update_indexes.