-
Notifications
You must be signed in to change notification settings - Fork 369
Correctly Propagate Errors from Drop Entities #3693
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?
Correctly Propagate Errors from Drop Entities #3693
Conversation
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
Outdated
Show resolved
Hide resolved
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
Outdated
Show resolved
Hide resolved
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
Outdated
Show resolved
Hide resolved
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
Show resolved
Hide resolved
flyrain
left a comment
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.
Thanks @travis-bowen for the fix. LGTM overall. Left a few minor comments.
I'm not a big fan of the BaseResult and its subclasses, I think a better way is to create a set of exceptions which can be threw from the persistence layer(AtomicOperationMetaStoreManager, TransactionalMetaStoreManagerImpl). It's a different topic and fairly big change though. We could handle that later.
HonahX
left a comment
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.
Overall LGTM!
Quick question: Do we need ENTITY_UNDROPPABLE for table/view? I remember this is for service_admin and catalog_admin role which are not droppable.
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
Show resolved
Hide resolved
HonahX
left a comment
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.
Overall LGTM!
| return false; | ||
|
|
||
| case BaseResult.ReturnStatus.ENTITY_UNDROPPABLE: | ||
| throw new ForbiddenException( |
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 this for table/view? I remember this is for service_admin and catalog_admin role which are not droppable.
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.
You're right - we don't need it. I lean towards keeping it since we can't be certain of any custom implementations but I'm not tied to keeping it if you feel strongly.
During drop commands, Apache Polaris would make assumptions based on the entity type as to why the entity could not be dropped which could lead to incorrect user error messaging and handling.
Here I tackle updating error handling for DropTable, DropNamespace, and DropView.
The Catalog API javadocs by Iceberg indicate false should indicate [TableNotExists] (and simila for View) (https://github.com/apache/iceberg/blob/a8ece055ba93adc0c046db29b6b7b5edaf35d4da/api/src/main/java/org/apache/iceberg/catalog/Catalog.java#L292).
For Namespaces it's less clear, but I assume the same holds and we treat it to follow the same logic that false = Not Found in CatalogHandlerUtils.
Before
Any non success in Polaris's IcebergCatalog impl would return false.
Polaris's CatalogHandlerUtils would interpret this false to mean the entity did not exist and would throw the appropriate does not exist error
However, the reason that it returned false, may not truly be that it didn't exist.
After
The IcebergCatalog impl in Polaris uses the return status of the persistence result to determine whether or not the drop failure was due to being not found. If not found, it returns false per the interface definition, which the CatalogHandlerUtil transforms into the appropriate not found exception. Otherwise it throws it's own error corresponding to the cause.
Ran tests locally + S3 Tests with drop


Checklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)