Fix the race condition issue on updating caches. (#921706)