-
Notifications
You must be signed in to change notification settings - Fork 460
Return HTTP 503 on concurrent rename instead of 500 #4646
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -74,6 +74,7 @@ | |||||||||||||||||||||||||||||||
| import org.apache.iceberg.exceptions.NoSuchViewException; | ||||||||||||||||||||||||||||||||
| import org.apache.iceberg.exceptions.NotFoundException; | ||||||||||||||||||||||||||||||||
| import org.apache.iceberg.exceptions.ServiceFailureException; | ||||||||||||||||||||||||||||||||
| import org.apache.iceberg.exceptions.ServiceUnavailableException; | ||||||||||||||||||||||||||||||||
| import org.apache.iceberg.exceptions.UnprocessableEntityException; | ||||||||||||||||||||||||||||||||
| import org.apache.iceberg.io.CloseableGroup; | ||||||||||||||||||||||||||||||||
| import org.apache.iceberg.io.FileIO; | ||||||||||||||||||||||||||||||||
|
|
@@ -2494,10 +2495,22 @@ private void renameTableLike( | |||||||||||||||||||||||||||||||
| case BaseResult.ReturnStatus.ENTITY_NOT_FOUND: | ||||||||||||||||||||||||||||||||
| throw new NotFoundException("Cannot rename %s to %s. %s does not exist", from, to, from); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // this is temporary. Should throw a special error that will be caught and retried | ||||||||||||||||||||||||||||||||
| case BaseResult.ReturnStatus.TARGET_ENTITY_CONCURRENTLY_MODIFIED: | ||||||||||||||||||||||||||||||||
| // The source path (ENTITY_CANNOT_BE_RESOLVED) or the target path | ||||||||||||||||||||||||||||||||
| // (CATALOG_PATH_CANNOT_BE_RESOLVED) could not be resolved, e.g. because it was concurrently | ||||||||||||||||||||||||||||||||
| // dropped. This is not retriable, so surface it as 404. | ||||||||||||||||||||||||||||||||
| case BaseResult.ReturnStatus.ENTITY_CANNOT_BE_RESOLVED: | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should narrow down this to case
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Lines 1205 to 1207 in 005e889
Lines 1238 to 1240 in 005e889
I'd note though that the NoSQL persistence does not raise I'd suggest to group them together and throw However, polaris/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/entity/BaseResult.java Lines 76 to 84 in 46e6891
I actually think the comments are wrong. If either the old or new path has been deleted by a concurrent commit, clients should not retry.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting info, but IIRC
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ALWAYS get fooled by its name 😅 Looking at
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting... 🤔 @vigneshio : How did you hit these errors in practice?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||||||||
| throw new RuntimeException("concurrent update detected, please retry"); | ||||||||||||||||||||||||||||||||
| case BaseResult.ReturnStatus.CATALOG_PATH_CANNOT_BE_RESOLVED: | ||||||||||||||||||||||||||||||||
| throw new NoSuchNamespaceException( | ||||||||||||||||||||||||||||||||
| "Cannot rename %s to %s because the source or target path could not be resolved", | ||||||||||||||||||||||||||||||||
| from, to); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // The entity is still present but was concurrently modified: a genuine transient conflict. | ||||||||||||||||||||||||||||||||
| // Surface as 503 so clients can retry. We avoid 409 because the rename endpoint reserves | ||||||||||||||||||||||||||||||||
| // 409 for "target already exists" (handled by the ENTITY_ALREADY_EXISTS case above). | ||||||||||||||||||||||||||||||||
| case BaseResult.ReturnStatus.TARGET_ENTITY_CONCURRENTLY_MODIFIED: | ||||||||||||||||||||||||||||||||
| throw new ServiceUnavailableException( | ||||||||||||||||||||||||||||||||
| "Cannot rename %s to %s because it was concurrently modified; please retry", | ||||||||||||||||||||||||||||||||
| from, to); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // some entities cannot be renamed | ||||||||||||||||||||||||||||||||
| case BaseResult.ReturnStatus.ENTITY_CANNOT_BE_RENAMED: | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
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.
If the goal is to tackle concurrent renames, I think we need to handle
CATALOG_PATH_CANNOT_BE_RESOLVEDas well. It's raised when a catalog path resolution fails during a write, seeTransactionalMetaStoreManagerImpl.renameEntity(). I suggest it be mapped toNoSuchNamespaceException.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.
SGTM 👍