[#11891] fix(lance): retry repair-on-load metadata update on optimistic-lock conflict#11892
Open
yuqi1129 wants to merge 3 commits into
Open
[#11891] fix(lance): retry repair-on-load metadata update on optimistic-lock conflict#11892yuqi1129 wants to merge 3 commits into
yuqi1129 wants to merge 3 commits into
Conversation
…timistic-lock conflict
repairTableMetadata and recordCheckedEmptyVersion run an optimistic-locked
EntityStore.update on every loadTable. Concurrent loads repairing the same table
race on the version CAS; the loser gets IOException("Failed to update the
entity"), which was rethrown as a fatal RuntimeException (HTTP 500).
Wrap the update in a bounded CAS retry (updateTableWithCasRetry): on conflict,
re-read the latest already-repaired entity and re-apply the idempotent updater,
returning a usable table instead of failing the load.
Fix: apache#11891
Signed-off-by: yuqi <yuqi@datastrato.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Lance table loadTable robustness under concurrent “repair-on-load” by adding a bounded retry loop around optimistic-lock (EntityStore.update) failures, preventing intermittent HTTP 500s when concurrent loads race to repair the same table metadata.
Changes:
- Add
updateTableWithCasRetry(max 5 attempts) and route repair-on-load updates through it to tolerate lost optimistic-lock CAS races. - Apply the retry wrapper to both
repairTableMetadataandrecordCheckedEmptyVersion. - Add a unit test reproducing the CAS-loss scenario and asserting
loadTablereturns a usable, repaired table instead of failing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/lance/LanceTableOperations.java |
Introduces a bounded retry for optimistic-lock update conflicts during repair-on-load paths. |
catalogs/catalog-lakehouse-generic/src/test/java/org/apache/gravitino/catalog/lakehouse/lance/TestLanceTableOperations.java |
Adds a regression test that models a lost CAS on the first update and validates recovery via retry. |
Code Coverage Report
Files
|
Contributor
|
Why has this been happening so frequently recently? |
Contributor
Author
I haven't seen this problem until today, and will follow it up for the next few weeks. It should not happen so frequently, theoretically. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
LanceTableOperations.repairTableMetadataandrecordCheckedEmptyVersionrun an optimistic-lockedEntityStore.updateon everyloadTable. When two loads repair the same table concurrently, the slower CAS matches zero rows and surfaces asIOException("Failed to update the entity"), which was rethrown as a fatalRuntimeException("Failed to repair table")(HTTP 500).This wraps that update in a bounded CAS retry (
updateTableWithCasRetry, 5 attempts): on conflict it re-reads the latest (already-repaired) entity and re-applies the idempotent updater, returning a usable table instead of failing.Why are the changes needed?
Concurrent repair-on-load races (e.g. Spark parallel
LOADduring planning + execution) intermittently fail table loads with HTTP 500. Seen as flakyLanceSparkRESTServiceIT.testSelectFromEmptyTableViaSpark.Fix: #11891
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added
TestLanceTableOperations.testLoadTableSurvivesConcurrentRepairVersionRace: it models a lost CAS (firststore.updatethrows the conflictIOException, the retry re-reads the winner's already-repaired entity) and assertsloadTablereturns the repaired table. It fails before the fix and passes after. The fullTestLanceTableOperationssuite (23 tests) passes locally.