JoegenUSTC opened a new pull request, #11846: URL: https://github.com/apache/gravitino/pull/11846
### What changes were proposed in this pull request? This PR is now based on the catalog lease from #12404. - Replace `CapabilityHelpers.getCapability` with `CapabilityHelpers.withCapability(ident, catalogManager, fn)`. It runs `fn` on the catalog `Capability` while a catalog lease is held and the catalog ClassLoader is the thread context ClassLoader. Only the computed value leaves the call. The capability object does not. - Migrate all callers: the Table, Partition, Fileset, View, Topic, Model, Function, Schema and Semantic Model normalize dispatchers, and `normalizeMetadataIdentifier` (used by tag and authorization lookups). `fn` only computes names and changes. Backend, physical-name and entity-store calls run after the lease is released. - Exceptions thrown by `fn`, such as an invalid name, reach the caller unchanged. Failures to load the catalog or its capability are still wrapped, as before. - Replace the enum `switch` in `HiveCatalogCapability.caseSensitiveOnName` and `GlueCatalogCapability.caseSensitiveOnName` with `if`/`else`, so javac emits no `$1` switch-map class. Both now reject a `null` scope. The earlier `synchronized` `doWithCapabilityOps`/`close()` and the closed-wrapper retry are removed. The lease already keeps the wrapper open during a call, and it reloads a retired wrapper before `fn` runs, so `fn` runs at most once. List results are returned as the catalog returns them. ### Why are the changes needed? `getCapability` took a lease, read the capability and released the lease. The caller then used the capability. If the catalog was evicted in between, its ClassLoader could be closed. A capability method that loads a class on first use, such as an enum switch that loads `HiveCatalogCapability$1`, then fails with `NoClassDefFoundError`. Fix: #11726 ### Does this PR introduce _any_ user-facing change? No. There are no API, REST or configuration changes. `CapabilityHelpers.getCapability` is removed. It is an internal core helper with no production callers outside core. ### How was this patch tested? - `TestCatalogWrapperLease`: a catalog evicted while `withCapability` runs keeps its catalog until `fn` returns, and is cleaned up afterwards. A normalize dispatcher calls the backend with no lease held. - `TestCapabilityHelpers`: `fn` runs inside the catalog call; `fn` exceptions are not wrapped; `NoSuchCatalogException` and capability load failures keep their behavior. - `TestHiveCatalogCapability`, `TestGlueCatalogCapability`: every scope, `null` scope, and no `$1` class. - Reverting `withCapability` to use the capability after the lease is released makes the new lease and helper tests fail. - Ran 29 core test classes that use the changed code (385 tests, including all normalize and hook dispatcher tests, `TestCatalogManager`, `TestTableOperationDispatcher` and `TestViewOperationDispatcher`), `TestNormalizedOwnerOperations` on H2, `TestJcasbinModelCacheInvalidation`, `TestMetadataIdConverter`, `TestJcasbinAuthorizationLookups`, and the Hive and Glue capability tests. All passed. The full core suite and integration tests were not run. -- 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]
