yuqi1129 opened a new pull request, #12240:
URL: https://github.com/apache/gravitino/pull/12240
### What changes were proposed in this pull request?
Make `IcebergCatalogUtil.loadJdbcCatalog` resilient to Iceberg's
non-idempotent V1 view-support migration when multiple Iceberg JDBC catalogs
share one backend `uri`:
- When `JdbcCatalog.initialize` fails with a duplicate `iceberg_type` column
error (another catalog on the same `uri` already ran the migration against the
shared `iceberg_tables`), re-initialize a fresh catalog once. The column now
exists, Iceberg skips the migration, and initialization completes.
- Add a package-private
`isConcurrentViewMigrationConflict(UncheckedSQLException)` classifier that
recognizes the duplicate-column error across backends (MySQL / PostgreSQL /
SQLite wordings).
- Minor: hoist the auth-mode branching out of the `try` (no behavior change)
and null-guard the existing "Access denied" message check.
### Why are the changes needed?
Iceberg creates `iceberg_tables` without the `iceberg_type` column and then
adds it via a non-idempotent `ALTER TABLE ... ADD COLUMN` in
`updateSchemaIfRequired` (Gravitino defaults `jdbc.schema-version=V1`). Two
Iceberg JDBC catalogs on the same `uri` share one `iceberg_tables`, so a losing
racer fails init with:
```
Caused by: java.sql.SQLSyntaxErrorException: Duplicate column name
'iceberg_type'
at
org.apache.iceberg.jdbc.JdbcCatalog.executeV1CatalogUpdate(JdbcCatalog.java:276)
at
org.apache.iceberg.jdbc.JdbcCatalog.updateSchemaIfRequired(JdbcCatalog.java:235)
```
This surfaced as flakiness in
`IcebergClassLoaderPoolIT.testDropOneSharedCatalogKeepsSiblingUsable`
(deploy/MySQL), but affects any real deployment loading two Iceberg JDBC
catalogs on the same JDBC `uri`.
Fix: #12237
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
- New unit tests in `TestIcebergCatalogUtil` covering the classifier across
MySQL/PostgreSQL/SQLite duplicate-column messages and negative cases (wrong
column, non-duplicate `iceberg_type` mention, non-SQL cause, null message).
- `./gradlew :iceberg:iceberg-common:test --tests
"org.apache.gravitino.iceberg.common.utils.TestIcebergCatalogUtil"` — 15/15
pass; `spotlessCheck` passes.
--
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]