You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "gh-yzou (via GitHub)" <gi...@apache.org> on 2025/06/05 01:30:56 UTC
[PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
gh-yzou opened a new pull request, #1816:
URL: https://github.com/apache/polaris/pull/1816
We want to turn CallContext class into a pure interface that can be implemented/customized by its child class. This PR removes the copyOf static function.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2129116394
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,17 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public CallContext copy() {
+ // The realm context is a request scoped bean injected by CDI,
+ // which will be closed after the http request. This copy is currently
+ // only used by TaskExecutor right before the task is handled, since the
+ // task is executed outside the active request scope, we need to make a
+ // copy of the RealmContext to ensure the access during the task executor.
+ String realmId = this.realmContext.getRealmIdentifier();
+ RealmContext realmContext = () -> realmId;
+ return new PolarisCallContext(
+ realmContext, this.metaStore, this.diagServices, this.configurationStore, this.clock);
Review Comment:
Veering away from `@Singleton`. I'd like to avoid copying / cloning contexts completely and rely on CDI for injection in Quarkus. The open question here is how to deal with custom downstream builds that use `polaris-core` classes directly. I hope we can refactor that to allow for reuse via constructors and factories.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2127974372
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,13 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public PolarisCallContext copy() {
+ // make a copy of the realm context
Review Comment:
I think I knew why, but a comment was supposed to explain why instead of what. It's easier to know what we do here by reading the code, but harder to know why we do that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2127831933
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,13 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public PolarisCallContext copy() {
+ // make a copy of the realm context
Review Comment:
nit: can we explain why we need a realm context copy here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2129012375
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,17 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public CallContext copy() {
+ // The realm context is a request scoped bean injected by CDI,
+ // which will be closed after the http request. This copy is currently
+ // only used by TaskExecutor right before the task is handled, since the
+ // task is executed outside the active request scope, we need to make a
+ // copy of the RealmContext to ensure the access during the task executor.
+ String realmId = this.realmContext.getRealmIdentifier();
+ RealmContext realmContext = () -> realmId;
+ return new PolarisCallContext(
+ realmContext, this.metaStore, this.diagServices, this.configurationStore, this.clock);
Review Comment:
By the logic of the comment makes sense to me in general.
However, I do not think it matters in practice ATM, because `RealmContext` implementations are not really closable. Those objects are quite usable (via latent references) even after the associated request context is destroyed.
This PR LGTM as an incremental improvement. In the future, I'd like to manage all contextual data via injection (automated in Quarkus CDI runtime or manual in customized env.)
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,17 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public CallContext copy() {
+ // The realm context is a request scoped bean injected by CDI,
+ // which will be closed after the http request. This copy is currently
+ // only used by TaskExecutor right before the task is handled, since the
+ // task is executed outside the active request scope, we need to make a
+ // copy of the RealmContext to ensure the access during the task executor.
+ String realmId = this.realmContext.getRealmIdentifier();
+ RealmContext realmContext = () -> realmId;
+ return new PolarisCallContext(
+ realmContext, this.metaStore, this.diagServices, this.configurationStore, this.clock);
Review Comment:
The logic of the comment makes sense to me in general.
However, I do not think it matters in practice ATM, because `RealmContext` implementations are not really closable. Those objects are quite usable (via latent references) even after the associated request context is destroyed.
This PR LGTM as an incremental improvement. In the future, I'd like to manage all contextual data via injection (automated in Quarkus CDI runtime or manual in customized env.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2129064473
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,17 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public CallContext copy() {
+ // The realm context is a request scoped bean injected by CDI,
+ // which will be closed after the http request. This copy is currently
+ // only used by TaskExecutor right before the task is handled, since the
+ // task is executed outside the active request scope, we need to make a
+ // copy of the RealmContext to ensure the access during the task executor.
+ String realmId = this.realmContext.getRealmIdentifier();
+ RealmContext realmContext = () -> realmId;
+ return new PolarisCallContext(
+ realmContext, this.metaStore, this.diagServices, this.configurationStore, this.clock);
Review Comment:
> Those objects are quite usable (via latent references) even after the associated request context is destroyed.
I am not entirely sure: if the bean is `@ApplicationScoped` then a proxy is created for it. This means that calling `RealmContext.getRealmIdentifier()` will fail if the context has been destroyed.
If however the bean is `@Singleton`, I believe that yes, the bean would remain usable after the context is destroyed, because there is no proxy created for it.
This begs the question: should we use `@Singleton` whenever possible?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2127842577
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,13 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public PolarisCallContext copy() {
+ // make a copy of the realm context
Review Comment:
Yes, I was wondering about that too :)
One this that irks me is that a `RealmContext` impl. may not be immutable. We do not know that here. However, it's a minor point, IMHO.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2127811099
##########
service/common/src/testFixtures/java/org/apache/polaris/service/TestServices.java:
##########
@@ -163,22 +163,12 @@ public TestServices build() {
BasePersistence metaStoreSession =
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get();
CallContext callContext =
- new CallContext() {
- @Override
- public RealmContext getRealmContext() {
- return realmContext;
- }
-
- @Override
- public PolarisCallContext getPolarisCallContext() {
- return new PolarisCallContext(
- realmContext,
- metaStoreSession,
- polarisDiagnostics,
- configurationStore,
- Mockito.mock(Clock.class));
- }
- };
+ new PolarisCallContext(
+ realmContext,
+ metaStoreSession,
+ polarisDiagnostics,
+ configurationStore,
+ Mockito.mock(Clock.class));
Review Comment:
nit: `Clock.systemUTC()` is simpler.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "gh-yzou (via GitHub)" <gi...@apache.org>.
gh-yzou commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2128014409
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,13 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public PolarisCallContext copy() {
+ // make a copy of the realm context
Review Comment:
yes, added, please take a look and see if it make sense
##########
service/common/src/testFixtures/java/org/apache/polaris/service/TestServices.java:
##########
@@ -163,22 +163,12 @@ public TestServices build() {
BasePersistence metaStoreSession =
metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get();
CallContext callContext =
- new CallContext() {
- @Override
- public RealmContext getRealmContext() {
- return realmContext;
- }
-
- @Override
- public PolarisCallContext getPolarisCallContext() {
- return new PolarisCallContext(
- realmContext,
- metaStoreSession,
- polarisDiagnostics,
- configurationStore,
- Mockito.mock(Clock.class));
- }
- };
+ new PolarisCallContext(
+ realmContext,
+ metaStoreSession,
+ polarisDiagnostics,
+ configurationStore,
+ Mockito.mock(Clock.class));
Review Comment:
sg! updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain merged PR #1816:
URL: https://github.com/apache/polaris/pull/1816
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2129107815
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,17 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public CallContext copy() {
+ // The realm context is a request scoped bean injected by CDI,
+ // which will be closed after the http request. This copy is currently
+ // only used by TaskExecutor right before the task is handled, since the
+ // task is executed outside the active request scope, we need to make a
+ // copy of the RealmContext to ensure the access during the task executor.
+ String realmId = this.realmContext.getRealmIdentifier();
+ RealmContext realmContext = () -> realmId;
+ return new PolarisCallContext(
+ realmContext, this.metaStore, this.diagServices, this.configurationStore, this.clock);
Review Comment:
Good point about proxies :+1: I sand corrected :facepalm:
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,17 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public CallContext copy() {
+ // The realm context is a request scoped bean injected by CDI,
+ // which will be closed after the http request. This copy is currently
+ // only used by TaskExecutor right before the task is handled, since the
+ // task is executed outside the active request scope, we need to make a
+ // copy of the RealmContext to ensure the access during the task executor.
+ String realmId = this.realmContext.getRealmIdentifier();
+ RealmContext realmContext = () -> realmId;
+ return new PolarisCallContext(
+ realmContext, this.metaStore, this.diagServices, this.configurationStore, this.clock);
Review Comment:
Good point about proxies :+1: I stand corrected :facepalm:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2128685536
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,17 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public CallContext copy() {
Review Comment:
nit:
```suggestion
public PolarisCallContext copy() {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2128688478
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,13 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public PolarisCallContext copy() {
+ // make a copy of the realm context
Review Comment:
The added text LGTM 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Turn CallContext.copyOf into an interface instead of static function [polaris]
Posted by "gh-yzou (via GitHub)" <gi...@apache.org>.
gh-yzou commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2129307490
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,17 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public CallContext copy() {
Review Comment:
updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org