You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "dimas-b (via GitHub)" <gi...@apache.org> on 2026/01/10 00:13:48 UTC
[PR] Use new Request Context for each realm during implicit bootstrap [polaris]
dimas-b opened a new pull request, #3411:
URL: https://github.com/apache/polaris/pull/3411
The implicit (auto) bootstrap calls used to share Request Context for potentially many realms. That used to work by coincidence because `RealmConfig`, for example, is a `RequestScoped` bean.
With this change each realm will be bootstrapped in its own dedicated Request Context.
This change lays down a foundation for future refactoring related to `RealmConfig`.
<!--
๐ Describe what changes you're proposing, especially breaking or user-facing changes.
๐ See https://github.com/apache/polaris/blob/main/CONTRIBUTING.md for more.
-->
## 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)
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2687997893
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
Review Comment:
changed to ctor-based injection
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2683382589
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
+
+ PrincipalSecretsResult bootstrapRealm(String realmId, RootCredentialsSet rootCredentialsSet) {
Review Comment:
Wouldn't it be better to return a `CompletionStage`, then combine them all and wait for the combined result?
##########
runtime/service/src/main/java/org/apache/polaris/service/config/ServiceProducers.java:
##########
@@ -285,7 +287,13 @@ public void maybeBootstrap(
RootCredentialsSet.ENVIRONMENT_VARIABLE,
RootCredentialsSet.SYSTEM_PROPERTY);
- var result = factory.bootstrapRealms(realmIds, rootCredentialsSet);
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
Review Comment:
I think this should be moved to `Bootstrapper` as well. The `Bootstrapper` should take a set of ream ids as input and return a `Map<String, PrincipalSecretsResult>`. Wdyt?
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2687992742
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
Review Comment:
Generic pool would be nice, indeed, but I'm not sure about CDI implications there :thinking: The `task-executor` pool is known NOT to propagate CDI context to tasks (#3210)
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2682514285
##########
runtime/service/src/main/java/org/apache/polaris/service/config/ServiceProducers.java:
##########
@@ -285,7 +287,13 @@ public void maybeBootstrap(
RootCredentialsSet.ENVIRONMENT_VARIABLE,
RootCredentialsSet.SYSTEM_PROPERTY);
- var result = factory.bootstrapRealms(realmIds, rootCredentialsSet);
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
+ for (String realmId : realmIds) {
+ PrincipalSecretsResult r = bootstrapper.bootstrapRealm(realmId, rootCredentialsSet);
+ if (r != null) {
+ result.put(realmId, r);
+ }
+ }
result.forEach(
Review Comment:
True, but I did not want to change API in this PR :wink:
##########
runtime/service/src/main/java/org/apache/polaris/service/config/ServiceProducers.java:
##########
@@ -285,7 +287,13 @@ public void maybeBootstrap(
RootCredentialsSet.ENVIRONMENT_VARIABLE,
RootCredentialsSet.SYSTEM_PROPERTY);
- var result = factory.bootstrapRealms(realmIds, rootCredentialsSet);
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
+ for (String realmId : realmIds) {
+ PrincipalSecretsResult r = bootstrapper.bootstrapRealm(realmId, rootCredentialsSet);
+ if (r != null) {
+ result.put(realmId, r);
+ }
+ }
result.forEach(
Review Comment:
Makes sense - will fix
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2684183936
##########
runtime/service/src/main/java/org/apache/polaris/service/config/ServiceProducers.java:
##########
@@ -285,7 +287,13 @@ public void maybeBootstrap(
RootCredentialsSet.ENVIRONMENT_VARIABLE,
RootCredentialsSet.SYSTEM_PROPERTY);
- var result = factory.bootstrapRealms(realmIds, rootCredentialsSet);
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
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
Re: [PR] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2684184667
##########
runtime/service/src/main/java/org/apache/polaris/service/config/ServiceProducers.java:
##########
@@ -285,7 +287,13 @@ public void maybeBootstrap(
RootCredentialsSet.ENVIRONMENT_VARIABLE,
RootCredentialsSet.SYSTEM_PROPERTY);
- var result = factory.bootstrapRealms(realmIds, rootCredentialsSet);
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
+ for (String realmId : realmIds) {
+ PrincipalSecretsResult r = bootstrapper.bootstrapRealm(realmId, rootCredentialsSet);
+ if (r != null) {
+ result.put(realmId, r);
+ }
+ }
result.forEach(
Review Comment:
I went with @adutra 's suggestion... WDYT?
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2687225936
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
Review Comment:
changed to ctor-based injection
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
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
Re: [PR] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2687126440
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
+
+ Map<String, PrincipalSecretsResult> bootstrapRealms(
+ Iterable<String> realmIds, RootCredentialsSet rootCredentialsSet) {
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
+ for (String realmId : realmIds) {
+ Task t = new Task(realmContextHolder, realmId, rootCredentialsSet, factory);
+ try {
+ // Submit an async task per realm to ensure it runs in a fresh RequestContext.
+ // Note: simultaneous bootstrap of multiple realms is an edge case - no need
+ // to optimize for fast concurrent completion.
+ result.putAll(executor.submit(t).get(2, TimeUnit.MINUTES));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return result;
+ }
+
+ private record Task(
+ RealmContextHolder realmContextHolder,
+ String realmId,
+ RootCredentialsSet rootCredentialsSet,
+ MetaStoreManagerFactory factory)
Review Comment:
Sorry, I do not understand this suggestion :thinking: What does it mean to achieve?
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2685180602
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
Review Comment:
```suggestion
AsyncExec executor;
```
Would prevent a dependency from bootstrapping to the current tasks implementation.
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
+
+ Map<String, PrincipalSecretsResult> bootstrapRealms(
+ Iterable<String> realmIds, RootCredentialsSet rootCredentialsSet) {
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
+ for (String realmId : realmIds) {
+ Task t = new Task(realmContextHolder, realmId, rootCredentialsSet, factory);
Review Comment:
```suggestion
Task t = new Task(realmId, rootCredentialsSet);
```
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
Review Comment:
```suggestion
class Bootstrapper {
```
Don't think this type should be used from other packages.
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
+
+ Map<String, PrincipalSecretsResult> bootstrapRealms(
+ Iterable<String> realmIds, RootCredentialsSet rootCredentialsSet) {
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
+ for (String realmId : realmIds) {
+ Task t = new Task(realmContextHolder, realmId, rootCredentialsSet, factory);
+ try {
+ // Submit an async task per realm to ensure it runs in a fresh RequestContext.
+ // Note: simultaneous bootstrap of multiple realms is an edge case - no need
+ // to optimize for fast concurrent completion.
+ result.putAll(executor.submit(t).get(2, TimeUnit.MINUTES));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return result;
+ }
+
+ private record Task(
+ RealmContextHolder realmContextHolder,
+ String realmId,
+ RootCredentialsSet rootCredentialsSet,
+ MetaStoreManagerFactory factory)
Review Comment:
```suggestion
String realmId,
RootCredentialsSet rootCredentialsSet)
```
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
Review Comment:
```suggestion
@Inject RealmContextHolder realmContextHolder;
@Inject MetaStoreManagerFactory factory;
```
[Less work](https://quarkus.io/guides/cdi-reference#quarkus-arc_quarkus-arc-transform-private-injected-fields) for DI instrumentation in Quarkus, and potentially nicer for Weld.
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
Review Comment:
```suggestion
ExecutorService executor;
```
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2687149565
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
+
+ Map<String, PrincipalSecretsResult> bootstrapRealms(
+ Iterable<String> realmIds, RootCredentialsSet rootCredentialsSet) {
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
+ for (String realmId : realmIds) {
+ Task t = new Task(realmContextHolder, realmId, rootCredentialsSet, factory);
Review Comment:
ah, yea - it would need to be non-static.
Let's maybe discard my comment then.
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2683403586
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
+
+ PrincipalSecretsResult bootstrapRealm(String realmId, RootCredentialsSet rootCredentialsSet) {
Review Comment:
I wanted to maintain old sequential bootstrap logic... this is not a main call path in real deployments, so I guess efficiency is not critical :thinking:
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b merged PR #3411:
URL: https://github.com/apache/polaris/pull/3411
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2683406535
##########
runtime/service/src/main/java/org/apache/polaris/service/config/ServiceProducers.java:
##########
@@ -285,7 +287,13 @@ public void maybeBootstrap(
RootCredentialsSet.ENVIRONMENT_VARIABLE,
RootCredentialsSet.SYSTEM_PROPERTY);
- var result = factory.bootstrapRealms(realmIds, rootCredentialsSet);
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
Review Comment:
Yes, I'll move the map to `Bootstrapper`, but I'll keep sequential execution for now, if you do not mind :)
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2682514285
##########
runtime/service/src/main/java/org/apache/polaris/service/config/ServiceProducers.java:
##########
@@ -285,7 +287,13 @@ public void maybeBootstrap(
RootCredentialsSet.ENVIRONMENT_VARIABLE,
RootCredentialsSet.SYSTEM_PROPERTY);
- var result = factory.bootstrapRealms(realmIds, rootCredentialsSet);
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
+ for (String realmId : realmIds) {
+ PrincipalSecretsResult r = bootstrapper.bootstrapRealm(realmId, rootCredentialsSet);
+ if (r != null) {
+ result.put(realmId, r);
+ }
+ }
result.forEach(
Review Comment:
True, but I did not want to change API in this PR :wink:
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2687129503
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
+
+ Map<String, PrincipalSecretsResult> bootstrapRealms(
+ Iterable<String> realmIds, RootCredentialsSet rootCredentialsSet) {
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
+ for (String realmId : realmIds) {
+ Task t = new Task(realmContextHolder, realmId, rootCredentialsSet, factory);
Review Comment:
Do you mean `Task` to be a proper inner class (not static)?
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2687147184
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
+
+ Map<String, PrincipalSecretsResult> bootstrapRealms(
+ Iterable<String> realmIds, RootCredentialsSet rootCredentialsSet) {
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
+ for (String realmId : realmIds) {
+ Task t = new Task(realmContextHolder, realmId, rootCredentialsSet, factory);
+ try {
+ // Submit an async task per realm to ensure it runs in a fresh RequestContext.
+ // Note: simultaneous bootstrap of multiple realms is an edge case - no need
+ // to optimize for fast concurrent completion.
+ result.putAll(executor.submit(t).get(2, TimeUnit.MINUTES));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return result;
+ }
+
+ private record Task(
+ RealmContextHolder realmContextHolder,
+ String realmId,
+ RootCredentialsSet rootCredentialsSet,
+ MetaStoreManagerFactory factory)
Review Comment:
Oops, looks the text didn't make it...
The record's code can use the outer fields.
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2687230036
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
Review Comment:
Not sure I understand this, sorry... Could you explain is another way :thinking:
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2687353964
##########
runtime/service/src/main/java/org/apache/polaris/service/config/Bootstrapper.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.control.ActivateRequestContext;
+import jakarta.inject.Inject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
+import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult;
+import org.apache.polaris.service.context.catalog.RealmContextHolder;
+
+/** Utility class for running per-realm bootstrap tasks each in a fresh Request Context. */
+@ApplicationScoped
+public class Bootstrapper {
+ @Inject private RealmContextHolder realmContextHolder;
+ @Inject private MetaStoreManagerFactory factory;
+
+ // Note: this executor is expected to NOT propagate CDI contexts to tasks.
+ @Inject
+ @Identifier("task-executor")
+ private ExecutorService executor;
Review Comment:
`task-executor` is IIRC used to run the tasks. Not a big deal, just thinking it could be nice to use a "generic" pool.
--
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] Use new Request Context for each realm during implicit bootstrap [polaris]
Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #3411:
URL: https://github.com/apache/polaris/pull/3411#discussion_r2681221765
##########
runtime/service/src/main/java/org/apache/polaris/service/config/ServiceProducers.java:
##########
@@ -285,7 +287,13 @@ public void maybeBootstrap(
RootCredentialsSet.ENVIRONMENT_VARIABLE,
RootCredentialsSet.SYSTEM_PROPERTY);
- var result = factory.bootstrapRealms(realmIds, rootCredentialsSet);
+ HashMap<String, PrincipalSecretsResult> result = new HashMap<>();
+ for (String realmId : realmIds) {
+ PrincipalSecretsResult r = bootstrapper.bootstrapRealm(realmId, rootCredentialsSet);
+ if (r != null) {
+ result.put(realmId, r);
+ }
+ }
result.forEach(
Review Comment:
Looks like this function doesn't really need `Map<> results` anymore, only to populate `unusedRealmSecrets` below.
--
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