-
Notifications
You must be signed in to change notification settings - Fork 314
Request-scoped PolarisMetaStoreManager #2555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
9738d71
to
c014ca0
Compare
c1b2564
to
4511b5e
Compare
ebc2443
to
e9f1079
Compare
e9f1079
to
88db62e
Compare
88db62e
to
d1dda2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
partial review
public PolarisMetaStoreManager createMetaStoreManager( | ||
RealmContext realmContext, @Nullable RealmConfig realmConfig) { | ||
if (realmConfig == null) { | ||
realmConfig = new RealmConfigImpl(configurationStore, realmContext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the realmConfig
parameter at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as we can build it ourselves its not strictly needed no, but many call sites already have it and can pass it in.
i am fine to remove the parameter if we think thats better overall.
public class InMemoryEntityCache implements EntityCache { | ||
|
||
private final PolarisDiagnostics diagnostics; | ||
private final PolarisMetaStoreManager polarisMetaStoreManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose InMemoryEntityCache must use a PolarisMetaStoreManager from the same realm. If PolarisMetaStoreManager
is a method parameter it become not so obvious. WDYT about keeping this field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaict we cant keep this field as PolarisMetaStoreManager
now represents a (per-request) persistence session where-as InMemoryEntityCache
is supposed to be a shared cache within a realm.
the question is with what persistence session do we want to populate the cache?
a shared one or the request-scoped one given by the callers as "use this for loading in case cache entry is missing" ?
d1dda2e
to
37696b7
Compare
rebased after trivial a conflict and also to adjust to |
the `PolarisMetaStoreManager` interface methods all take a `PolarisCallContext` parameter because they need access to `PolarisCallContext.getMetaStore` aka the persistence session. also occasionally the `RealmContext` and `RealmConfig` is needed. this means `PolarisMetaStoreManager` is only usable within a request-scope. `MetaStoreManagerFactory.getOrCreateMetaStoreManager` impls suggests that there needs to be one shared `PolarisMetaStoreManager` instance per realm. however if we look at the `PolarisMetaStoreManager` impls (`AtomicOperationMetaStoreManager` and `TransactionalMetaStoreManagerImpl`) we can see that they dont have any state themselves, the fields only reference application-scoped collaborators. those 2 observations combined mean that in order to reduce the dependency on `PolarisCallContext` the `PolarisMetaStoreManager` has to become request-scoped. note that if custom implementations would need any state sharing for a realm, they are still free to do so in their custom `MetaStoreManagerFactory` implementations, as they can initialize the request-scoped `PolarisMetaStoreManager` with whatever data they need. when `PolarisMetaStoreManager` is request-scoped the `getOrCreateSession` method also becomes a private implementation detail of the `MetaStoreManagerFactory`. the `EntityCache` / `InMemoryEntityCache` however can no longer operate on a single `PolarisMetaStoreManager` and the one from the request needs to be passed as a parameter in all the methods now.
37696b7
to
5007ca1
Compare
see ML discussion:
https://lists.apache.org/thread/ot19px6t0w808pp994rrc8kk7186dfxm
the
PolarisMetaStoreManager
interface methods all take aPolarisCallContext
parameterbecause they need access to
PolarisCallContext.getMetaStore
aka the persistence session.also occasionally the
RealmContext
andRealmConfig
is needed.this means
PolarisMetaStoreManager
is only usable within a request-scope.MetaStoreManagerFactory.getOrCreateMetaStoreManager
impls suggests that there needs tobe one shared
PolarisMetaStoreManager
instance per realm.however if we look at the
PolarisMetaStoreManager
impls (AtomicOperationMetaStoreManager
and
TransactionalMetaStoreManagerImpl
) we can see that they dont have any state themselves, the fields only reference application-scoped instances.Those 2 observations combined mean that we can make the
PolarisMetaStoreManager
request-scoped and then thePolarisCallContext
parameter can be removed from all the methods without losing any functionality/flexibility.note that if custom implementations would need any state sharing for a realm, they are still free to do so in their custom
MetaStoreManagerFactory
implementations, as they caninitialize the custom request-scoped
PolarisMetaStoreManager
instance with whatever (shared) data they need.when
PolarisMetaStoreManager
is request-scoped thegetOrCreateSession
method also becomes a private implementation detail of theMetaStoreManagerFactory
.