lintingbin opened a new pull request, #4185:
URL: https://github.com/apache/amoro/pull/4185

   $(cat <<'EOF'
   ## What changes were proposed in this pull request?
   
   Follow-up fix for AMORO-4163. The original fix changed `ops.current()` to 
`ops.refresh()` inside `InternalMixedIcebergHandler.newTableOperations()` so 
that the returned `TableMetadata` reference satisfies Iceberg 1.7.x's 
reference-equality check in `commit()`. However, this introduced a new race 
condition:
   
   `DefaultTableManager.createTable()` consists of two sequential steps:
   1. `catalog.createTable()` — saves the table to the database (the table is 
now visible to all threads)
   2. `onTableCreated()` → `triggerTableAdded()` → `newTableOperations()` → 
`ops.commit()` — tries to write `v2.metadata.json`
   
   The background `tableExplorerScheduler` runs `exploreInternalCatalog()` 
concurrently. If it scans the database between steps 1 and 2, it finds the new 
table (not yet in `tableRuntimeMap`) and also calls `triggerTableAdded()` → 
`newTableOperations()` → `ops.commit()`. Whichever thread wins writes 
`v2.metadata.json` first; the other then fails with:
   
   ```
   CommitFailedException: Version 2 already exists: 
.../base/metadata/v2.metadata.json
   ```
   
   **Fix**: catch `CommitFailedException` in the commit block, refresh to 
obtain the latest on-disk metadata, and proceed normally if a concurrent writer 
already committed the correct mixed-format properties. Re-throw only when the 
properties still differ after refresh, indicating a genuine conflict.
   
   ## How was this patch tested?
   
   The existing `CompatibilityCatalogTests.testNewCatalogLoadHistorical` in 
`TestInternalMixedCatalogService` covers this scenario — it was consistently 
failing in CI before this fix.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   EOF
   )


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to