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 2025/12/05 01:29:22 UTC

[PR] Make each task attempt run in a dedicated CDI request context [polaris]

dimas-b opened a new pull request, #3210:
URL: https://github.com/apache/polaris/pull/3210

   Currently, tasks inherit the CDI context from the requests that submitted them, but run asynchronously. Therefore, if the original request context ends, the task may not be able to use the expired beans for that context.
   
   This change makes each task run in its own dedicated CDI request context with `RealmContext` explicitly propagated in `TaskExecutorImpl`.
   
   Test-only error handlers are added to `TaskExecutorImpl` to facilitate detecting task errors during CI.
   
   Fixes #3203
   
   <!--
   ๐Ÿ“ 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] Make each task attempt run in a dedicated CDI request context [polaris]

Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #3210:
URL: https://github.com/apache/polaris/pull/3210#discussion_r2592896167


##########
runtime/service/src/main/java/org/apache/polaris/service/task/TaskExecutorImpl.java:
##########
@@ -207,8 +227,12 @@ protected void handleTask(
     }
   }
 
+  @ActivateRequestContext
   protected void handleTaskWithTracing(
       long taskEntityId, CallContext callContext, PolarisEventMetadata eventMetadata, int attempt) {
+    // Note: each call to this method runs in a new CDI request context
+    realmContextHolder.set(callContext.getRealmContext());

Review Comment:
   Actually, the realm-ID needs to be extracted earlier in `tryHandleTask` outside the async schedule



-- 
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] Make each task attempt run in a dedicated CDI request context [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b merged PR #3210:
URL: https://github.com/apache/polaris/pull/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] Make each task attempt run in a dedicated CDI request context [polaris]

Posted by "adnanhemani (via GitHub)" <gi...@apache.org>.
adnanhemani commented on code in PR #3210:
URL: https://github.com/apache/polaris/pull/3210#discussion_r2591702628


##########
runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAuthzTestBase.java:
##########
@@ -231,13 +232,9 @@ public void before(TestInfo testInfo) {
 
     RealmContext realmContext = testInfo::getDisplayName;
     QuarkusMock.installMockForType(realmContext, RealmContext.class);
+    realmContextHolder.set(realmContext);
     polarisContext = callContext.getPolarisCallContext();
 
-    ContainerRequestContext containerRequestContext = Mockito.mock(ContainerRequestContext.class);

Review Comment:
   nit: isn't this for Request ID? Is this causing some downstream issues?



-- 
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] Make each task attempt run in a dedicated CDI request context [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3210:
URL: https://github.com/apache/polaris/pull/3210#discussion_r2593226910


##########
runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAuthzTestBase.java:
##########
@@ -231,13 +232,9 @@ public void before(TestInfo testInfo) {
 
     RealmContext realmContext = testInfo::getDisplayName;
     QuarkusMock.installMockForType(realmContext, RealmContext.class);
+    realmContextHolder.set(realmContext);
     polarisContext = callContext.getPolarisCallContext();
 
-    ContainerRequestContext containerRequestContext = Mockito.mock(ContainerRequestContext.class);

Review Comment:
   Also, I confirmed (locally) that `PolarisAdminServiceAuthzTest` works without this piece of code on `main` too.



-- 
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] Make each task attempt run in a dedicated CDI request context [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on PR #3210:
URL: https://github.com/apache/polaris/pull/3210#issuecomment-3614949862

   @cccs-cat001 : FYI


-- 
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] Make each task attempt run in a dedicated CDI request context [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #3210:
URL: https://github.com/apache/polaris/pull/3210#discussion_r2592943825


##########
runtime/service/src/main/java/org/apache/polaris/service/task/TaskExecutorImpl.java:
##########
@@ -207,8 +227,12 @@ protected void handleTask(
     }
   }
 
+  @ActivateRequestContext
   protected void handleTaskWithTracing(
       long taskEntityId, CallContext callContext, PolarisEventMetadata eventMetadata, int attempt) {
+    // Note: each call to this method runs in a new CDI request context
+    realmContextHolder.set(callContext.getRealmContext());

Review Comment:
   good point - fixed



-- 
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