geoserver / geoserver-cloud

Cloud Native GeoServer is GeoServer ready to use in the cloud through dockerized microservices.
http://geoserver.org/geoserver-cloud
Other
244 stars 73 forks source link

Fix bug in CachingCatalogFacade's cascade eviction #466

Closed groldan closed 3 months ago

groldan commented 3 months ago

When a CatalogInfo is explicitly evicted in CachingCatalogFacade, due to a local mutating operation, or in reaction to remote event, any oher CatalogInfo that directly (e.g. StyleInfo->WorkspaceInfo), or indirecly (e.g. LayerInfo->ResourceInfo->StoreInfo->WorkspaceInfo) references the evicted object needs to also be evicted, in order to prevent stale object references being cached.

Previously, a multi-map of such references was maintained as a reverse index. But it had a bug where for example, renaming a workspace wouldn't evict the styles for that workspace. Additionally, it could lead to memory leaks.

This patch replaces it by partial traversal of the cache entries (see CachedReferenceCleaner), and fixes both issues.

The performance penalty is sub-millisecond to < 10ms on a large catalog (100k layers, 100k styles, 20k stores, 20k workspaces).