[Bug report] preloadOwner is not best-effort: an uninitialized GravitinoEnv fails the whole list request
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 90/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- authorization, backend
Research direction
Start in server authorization MetadataAuthzHelper.preloadOwner around line 552, then run the named TestMetadataObjectTagOperations tests with ./gradlew :server:test -PskipITs --tests "org.apache.gravitino.server.web.rest.TestMetadataObjectTagOperations". Done means an uninitialized GravitinoEnv no longer aborts list requests and testListTagsForObject, testListTagsForObjectUnderHierarchicalSchema, and testListTagsDeduplicatesDifferentAssignmentValues return 200.
Written by the indexing model from the issue text.
Description
Version
main branch
Describe what's wrong
MetadataAuthzHelper.preloadOwner is a best-effort cache warm-up - its catch (Exception e) logs and ignores any failure. But the entity-store lookup sits outside that try:
private static void preloadOwner(Entity.EntityType entityType, NameIdentifier[] nameIdentifiers) {
if (!GravitinoEnv.getInstance().cacheEnabled()) {
return;
}
EntityStore entityStore = GravitinoEnv.getInstance().entityStore(); // <-- outside the try
try {
entityStore.relationOperations().batchListEntitiesByRelation(...);
} catch (Exception e) {
LOG.warn("Ignore preloadOwner error:{}", e.getMessage(), e);
}
}
GravitinoEnv.entityStore() has Preconditions.checkArgument(initialized, "GravitinoEnv is not initialized."), so when the environment is not initialized that IllegalArgumentException escapes the warm-up, propagates out of MetadataAuthzHelper.filterByExpression, and fails the entire list request with HTTP 400 - even though nothing about the requested listing actually failed.
Error message and/or stacktrace
{"code":1001,"type":"IllegalArgumentException",
"message":"Failed to operate tag(s) operation [LIST] under object [object1.object2], reason [GravitinoEnv is not initialized.]"}
java.lang.IllegalArgumentException: GravitinoEnv is not initialized.
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:143)
at org.apache.gravitino.GravitinoEnv.entityStore(GravitinoEnv.java:261)
at org.apache.gravitino.server.authorization.MetadataAuthzHelper.preloadOwner(MetadataAuthzHelper.java:552)
at org.apache.gravitino.server.authorization.MetadataAuthzHelper.filterByExpression(MetadataAuthzHelper.java:364)
at org.apache.gravitino.server.web.rest.MetadataObjectTagOperations.lambda$listTagsForMetadataObject$9(MetadataObjectTagOperations.java:217)
How to reproduce
Version: main branch. Any list endpoint that routes through MetadataAuthzHelper.filterByExpression while GravitinoEnv is uninitialized returns 400. Observable on main with:
./gradlew :server:test -PskipITs --tests "org.apache.gravitino.server.web.rest.TestMetadataObjectTagOperations"
Three tests fail with 400 instead of 200: testListTagsForObject, testListTagsForObjectUnderHierarchicalSchema, testListTagsDeduplicatesDifferentAssignmentValues.
A booted server initializes GravitinoEnv, so production traffic does not hit this today - the defect is that a helper documented and coded as ignorable can still abort the request.
Additional context
Found while adding tag support for Semantic Models (#12615). The fix is to move the lookup inside the existing try.
- Dominant language
- Java
- Stars
- 3.2k
- Forks
- 940
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 364
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/gravitino
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
1.3.1 bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
All issues in apache/gravitino
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100