Fixes #5214: Successfully invalidates metadata cache in some corner cases