Problem
When a database or table is deleted, the related metadata caches are not being deleted.
Proposed solution
Following how last caches are cleaned up (see linked PRs below), we need to do the same for metadata caches.
Alternatives
N/A
Additional Context
See also: #25566 (comment)