Repository navigation
Conversation
| PolarisEntity currentLeaf = leafEntity; | ||
| EntityResult returnedEntityResult = null; | ||
| IcebergTableLikeEntity toEntity = null; | ||
| for (int attempt = 1; attempt <= maxAttempts; attempt++) { |
There was a problem hiding this comment.
Would it be possible to use the Tasks API from Iceberg. Example:
There was a problem hiding this comment.
done @adutra, switched the rename retry over to Iceberg's Tasks API, same pattern as CatalogHandlerUtils (retry, exponentialBackoff, onlyRetryOn). Thanks for checking!
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
orca-review-bot
left a comment
There was a problem hiding this comment.
Thanks for picking this up. Retrying after a concurrent commit looks right. The problem is the case where the competing operation is another rename: on the atomic manager the retry renames the already-moved table, and on the transactional manager it surfaces as a misleading 404 (details inline).
Unanchored items:
- Tests only stub
renameEntityto return the conflict status, so no real competing rename is exercised. Can we add one that really moves the source first, plus aRENAME_RETRY_MAX_ATTEMPTS=0case and arenameViewcase? - PR description is just
#4729. Can we add the motivation,Fixes #4729, and the 500→503 / 500→404 status-code changes? - Verified fine: authz is unchanged (handler authorizes before
renameTableLike), and the reload stays within the same catalog.
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| returnedEntityResult = new EntityResult(BaseResult.ReturnStatus.ENTITY_NOT_FOUND, null); | ||
| break; | ||
| } | ||
| currentLeaf = PolarisEntity.of(reloaded.getEntity()); |
There was a problem hiding this comment.
After reloading we retry with whatever the entity looks like now, but we never check it's still from. If the conflict came from another rename that already succeeded, the retry renames the moved table to to. AtomicOperationMetaStoreManager.renameEntity only checks the version and re-parents onto the path we pass in, so this succeeds silently. The other client's rename gets overwritten, and in the same-namespace case the table moves back into the original namespace. Can we check that the reloaded name and parent id still match from, and throw NoSuchTableException/NoSuchViewException if they don't?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
|
|
||
| // Source or destination path was concurrently dropped. This is non-retriable: the | ||
| // client must observe the new namespace state before issuing another rename. | ||
| case BaseResult.ReturnStatus.ENTITY_CANNOT_BE_RESOLVED: |
There was a problem hiding this comment.
On the transactional manager, this status also comes back when the source table was renamed by someone else: the resolver looks up the stale (parent, name) before it checks the version. In that case the namespace still exists. It's the table that's gone, so a 404 'namespace not found' sends the client looking in the wrong place. Should ENTITY_CANNOT_BE_RESOLVED map to NoSuchTableException/NoSuchViewException, and keep NoSuchNamespaceException only for CATALOG_PATH_CANNOT_BE_RESOLVED?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| // off and retry. We avoid 409 here because the Iceberg rename endpoint reserves it | ||
| // for "target already exists" (handled by the ENTITY_ALREADY_EXISTS case above). | ||
| case BaseResult.ReturnStatus.TARGET_ENTITY_CONCURRENTLY_MODIFIED: | ||
| throw new ServiceUnavailableException( |
There was a problem hiding this comment.
If the sleep is interrupted we break out early, but this message still says we made maxAttempts attempts. Can we track the actual attempt count and print that?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| .defaultValue(2) | ||
| .buildFeatureConfiguration(); | ||
|
|
||
| public static final FeatureConfiguration<Integer> RENAME_RETRY_MAX_ATTEMPTS = |
There was a problem hiding this comment.
Each retry sleeps on the request worker thread, and this flag has no upper bound. The default 3 is harmless, but a realm set to something large could keep threads busy under contention. Can we clamp it, e.g. to 10, in renameTableLike?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
vigneshio
left a comment
There was a problem hiding this comment.
Thanks @Sasilekha. Left a note on the retry reload.
| new EntityResult(BaseResult.ReturnStatus.ENTITY_NOT_FOUND, null)); | ||
| return; | ||
| } | ||
| leaf = PolarisEntity.of(reloaded.getEntity()); |
There was a problem hiding this comment.
After a reload, would you mind checking this is still from before we apply to? loadEntity is by id, so if another rename already moved the table, the retry would move it a second time and overwrite that rename.
There was a problem hiding this comment.
Done. After a reload we check the name and parent still match from before applying to. If another rename already moved the table we throw NoSuchTableException/NoSuchViewException instead of moving it again.
Stop a rename retry when the reloaded entity is no longer at the source name and parent, so an already-moved table is not renamed again.
vigneshio
left a comment
There was a problem hiding this comment.
Thanks @Sasilekha. LGTM..
dimas-b
left a comment
There was a problem hiding this comment.
Thanks for your contribution, @Sasilekha !
|
|
||
| ### Fixes | ||
|
|
||
| - `renameTable` and `renameView` now retry a concurrent modification of the source entity |
There was a problem hiding this comment.
This probably belongs in the "changes" section rather than "fixes"
| .exponentialBackoff( | ||
| COMMIT_MIN_RETRY_WAIT_MS_DEFAULT, | ||
| COMMIT_MAX_RETRY_WAIT_MS_DEFAULT, | ||
| COMMIT_TOTAL_RETRY_TIME_MS_DEFAULT, |
There was a problem hiding this comment.
These parameters should probably be configurable in Polaris.
| validateLocationsForRenamedTableLike( | ||
| subType, | ||
| from, | ||
| to, | ||
| IcebergTableLikeEntity.of(leafEntity), | ||
| resolvedEntities, | ||
| resolvedNewParentEntities); |
There was a problem hiding this comment.
This should be done on every retry (leafEntity is reloaded).
| if (isRetry.get()) { | ||
| EntityResult reloaded = | ||
| getMetaStoreManager() | ||
| .loadEntity( |
There was a problem hiding this comment.
I believe retries should use the same loading method as the "main" (old) execution path.
There was a problem hiding this comment.
TBH, implementing this properly may require bigger changes. Cf. https://lists.apache.org/thread/hygmo5mby1k56g5d480nnd56p11k5gvg
Note that internal RBAC grants may change between retries. If entities are reloaded and internal RBAC is "on", grants ought to be reloaded too, I believe.
@dennishuo : WDYT?
| 2.0 /* exponential */) | ||
| .onlyRetryOn(ConcurrentRenameException.class) | ||
| .run( | ||
| source -> { |
There was a problem hiding this comment.
It might be worth using a dedicated private method for the (retriable) body of the rename operation.
|
Heads-up: #5967 has been merged, so Could you rebase onto |
#4729