Skip to content

Fix purgeRealms in LocalPolarisMetaStoreManagerFactory does not clear entityCacheMap #4801

Description

@ayushtkn

Describe the bug

LocalPolarisMetaStoreManagerFactory.purgeRealms() removes entries from sessionSupplierMap and metaStoreManagerMap but does not remove the corresponding entry from entityCacheMap.

sessionSupplierMap.remove(realm);
metaStoreManagerMap.remove(realm);
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions