Skip to content

Fix purgeRealms in LocalPolarisMetaStoreManagerFactory does not clear entityCacheMap - #4803

Merged
dimas-b merged 1 commit into
apache:mainfrom
ayushtkn:4801
Jul 20, 2026
Merged

Fix purgeRealms in LocalPolarisMetaStoreManagerFactory does not clear entityCacheMap#4803
dimas-b merged 1 commit into
apache:mainfrom
ayushtkn:4801

Conversation

@ayushtkn

@ayushtkn ayushtkn commented Jun 17, 2026

Copy link
Copy Markdown
Member

Fixes: #4801

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

Copilot AI review requested due to automatic review settings June 17, 2026 04:16
@github-project-automation github-project-automation Bot moved this to PRs In Progress in Basic Kanban Board Jun 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR ensures purging realms also clears the per-realm entity cache so subsequent realm bootstraps don’t reuse stale cached state.

Changes:

  • Synchronize purgeRealms and remove the realm entry from entityCacheMap during purge.
  • Add a JUnit test validating that purgeRealms causes a fresh EntityCache instance to be created after re-bootstrap.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java Clears entityCacheMap on realm purge and synchronizes purgeRealms to keep map mutations thread-safe.
polaris-core/src/test/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactoryTest.java Adds regression test asserting cache instances aren’t reused after purge + re-bootstrap.

Comment on lines +63 to +64
return new TreeMapTransactionalPersistenceImpl(
diagnostics, store, Mockito.mock(), RANDOM_SECRETS);

@nandorKollar nandorKollar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Since the key of each map in this class is the realm ID, I'm wondering whether we could use a single ConcurrentHashMap instead of three separate maps. This map could associate each realm ID with a record containing (PolarisMetaStoreManager, EntityCache, Supplier<TransactionalPersistence>). I think this would allow us to avoid the synchronized methods, wouldn't it?

@dimas-b

dimas-b commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@nandorKollar : just FYI: this class is used in Apache Polaris code only on "in memory" persistence call paths.

So this fix in OSS is probably not very critical... especially considering https://lists.apache.org/thread/nzoljc1ohnsq4f5o28dh4opqkqw3p09h

Do you need this fix for a downstream build?

@nandorKollar

Copy link
Copy Markdown
Contributor

@nandorKollar : just FYI: this class is used in Apache Polaris code only on "in memory" persistence call paths.

So this fix in OSS is probably not very critical... especially considering https://lists.apache.org/thread/nzoljc1ohnsq4f5o28dh4opqkqw3p09h

Do you need this fix for a downstream build?

You were quicker than me. :) I wanted to mention the same after I submitted my comment, probably we should hold off on merging this, as as far as understood, the plan is to deprecate and remove this. No, afaik we don't need this fix downstream (@ayushtkn correct me if I'm wrong).

@dimas-b

dimas-b commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@dennishuo @collado-mike : WDYT about this fix?

@flyrain flyrain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Thanks @ayushtkn !

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Jul 14, 2026
@dimas-b
dimas-b merged commit 0aae2c1 into apache:main Jul 20, 2026
24 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix purgeRealms in LocalPolarisMetaStoreManagerFactory does not clear entityCacheMap

5 participants