Fix purgeRealms in LocalPolarisMetaStoreManagerFactory does not clear entityCacheMap
bugstale
### Describe the bug
`LocalPolarisMetaStoreManagerFactory.purgeRealms()` removes entries from `sessionSupplierMap` and `metaStoreManagerMap` but does not remove the corresponding entry from `entityCacheMap`.
https://github.com/apache/polaris/blob/638247647c27667697675df01d2163043121e656/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java#L136-L139
This means after a realm is purged and re-bootstrapped, `getOrCreateEntityCache()` returns the stale cache from the previous realm lifecycle — containing references to entities that no longer exist.
Additionally, `purgeRealms` is not `synchronized`, unlike the other map-mutating methods (`bootstrapRealms`, `getOrCreateMetaStoreManager`, `getOrCreateSession`), creating a potential race with
concurrent reads/writes to the shared maps.
### To Reproduce
_No response_
### Actual Behavior
Returns stale entires post rebootstrap
### Expected Behavior
should return fresh entries after bootstrap
### Additional context
_No response_
### System information
_No response_
1 条评论