Skip to content

Conversation

XN137
Copy link
Contributor

@XN137 XN137 commented Aug 1, 2025

unfinished WIP

@github-project-automation github-project-automation bot moved this to PRs In Progress in Basic Kanban Board Aug 1, 2025
@XN137 XN137 changed the title Remove polaris call context.get meta store Remove PolarisCallContext.getMetaStore Aug 1, 2025
@XN137 XN137 force-pushed the Remove-PolarisCallContext.getMetaStore branch 2 times, most recently from 5cd5875 to 407ccb8 Compare August 1, 2025 13:45
snazy
snazy previously approved these changes Aug 1, 2025
Copy link
Member

@snazy snazy left a comment

Choose a reason for hiding this comment

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

Love it!

@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Aug 1, 2025

BasePersistence ms = polarisCallContext.getMetaStore();
// hackish way to inspect internal metastore
BasePersistence metaStore = ((BaseMetaStoreManager<?>) polarisMetaStoreManager).getMetaStore();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
BasePersistence metaStore = ((BaseMetaStoreManager<?>) polarisMetaStoreManager).getMetaStore();
BasePersistence metaStore = getBasePersistence();

plus the implementation

  protected BasePersistence getBasePersistence() {
    return ((BaseMetaStoreManager<?>) polarisMetaStoreManager).getMetaStore();
  }

return PolarisStorageConfigurationInfo.deserialize(storageConfigInfoStr);
}

private final Supplier<MS> metaStoreSupplier;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: move above methods?

@XN137 XN137 force-pushed the Remove-PolarisCallContext.getMetaStore branch from 407ccb8 to 5bb113c Compare August 4, 2025 11:22
private final Supplier<MS> metaStoreSupplier;

public BaseMetaStoreManager(Supplier<MS> metaStoreSupplier) {
this.metaStoreSupplier = Suppliers.memoize(metaStoreSupplier::get);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is still unclear what the actual lifetime scope of the BasePersistence should be here.

on main its lifetime is bound to the PolarisCallContext.
when we use memoize here, we'd have a single instance per realm.
when we dont use memoize here, we would be creating more instances than before, because for example AtomicOperationMetaStoreManager#loadResolvedEntityByName calls AtomicOperationMetaStoreManager#createEntityIfNotExists internally, both of which call getMetaStore().

i am wondering if the subclasses of BaseMetaStoreManager would need to tell the base class how to use the Supplier, depending on whether their specific BasePersistence impl instance has state or not.

theoretically we could also let BaseMetaStoreManager have a cache keyed by PolarisCallContext to keep exactly the existing "instance per callcontext" semantics though it would look a bit hacky

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI A lot of the machinery behind the MetaStoreManager/BasePersistence interactions/factories exists precisely to enforce the contract that BasePersistence instances are bound to a PolarisCallContext lifetime and are RequestScoped.

If the request scoping wasn't necessary, indeed none of the indirection would be necessary. Similarly, machinery for making MetaStoreManager realm-scoped goes beyond vanilla @ApplicationScoped annotations in order to define/enforce realm-scoping.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as per my comment this is still WIP and i am figuring out the actual lifetime of the BasePersistence object.

if what you are saying is true and the currently suggested change would break an existing contract, how is it that no test in CI is failing?
can you help adding a test that covers this contract explicitly?
or at least describe how such a test would need to look like?
that would help a lot!

@snazy
Copy link
Member

snazy commented Aug 4, 2025

Hm,
we might have to defer this one for a bit. Looks like there are some cases that could change their behavior (although not covered in test cases) - the cases when the "logical operation" relies on the same BasePersistence being used for a couple operations - we have to at least verify that those cases do not change their behavior.

@XN137 XN137 force-pushed the Remove-PolarisCallContext.getMetaStore branch 4 times, most recently from 79c4b42 to 3d4cd6d Compare August 12, 2025 15:22
XN137 added 2 commits August 12, 2025 17:42
the functionality no longer needs to be publically available as it has
become a private implementation detail of the `MetaStoreManagerFactory`
@XN137 XN137 force-pushed the Remove-PolarisCallContext.getMetaStore branch from 3d4cd6d to ddfa332 Compare August 12, 2025 15:42
Copy link
Member

@snazy snazy left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this!

Both types (meta-store-manager + base-persistence) are request-scoped. On top, only persistence internals use the base-persistence one. So exposing that feels odd. Hence +1 on this approach!

Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Sep 22, 2025
@snazy snazy removed the Stale label Sep 22, 2025
@XN137
Copy link
Contributor Author

XN137 commented Sep 24, 2025

closing as this will be replaced by #2555

@XN137 XN137 closed this Sep 24, 2025
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board Sep 24, 2025
@XN137 XN137 deleted the Remove-PolarisCallContext.getMetaStore branch September 24, 2025 07:53
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.

4 participants