Fixes #5598: Properly update metadata cache in update_metadata()