yuqi1129 opened a new pull request, #14903:
URL: https://github.com/apache/gravitino/pull/14903
### What changes were proposed in this pull request?
- Lance REST now handles `exist_ok` itself, in
`GravitinoLanceTableOperations.createTable`:
- It loads the table first. If the table exists and is a Lance table, it
returns that table and does not call `createTable`.
- If the table does not exist, it creates the table in `CREATE` mode.
- If a concurrent request created the table in between
(`TableAlreadyExistsException`), it loads that table and returns it. If that
table was dropped again, it reports the conflict.
- The generic catalog's `LanceTableOperations.createTable` now rejects
`lance.creation-mode=EXIST_OK` with `IllegalArgumentException` (HTTP 400). The
message names the table and says to load the table first or use the Lance REST
`exist_ok` mode.
- Update the docs and tests.
### Why are the changes needed?
`createTable` makes the caller the owner. Before this change, Lance REST
`exist_ok` sent a single `createTable` with `EXIST_OK`, and the catalog
returned the existing table. `TableHookDispatcher` then set the caller as the
owner of a table that already existed. So a user with only CREATE_TABLE could
become the owner of another user's table, and then drop it. The same was
possible through the Gravitino `createTable` API, because `lance.creation-mode`
is a normal table property.
Fixes #14436
### Does this PR introduce _any_ user-facing change?
Yes.
- Lance REST `exist_ok` on an existing table no longer changes its owner.
- The Gravitino Java and REST `createTable` no longer accept
`lance.creation-mode=EXIST_OK`. They return 400. Callers should load the table
first, or use the Lance REST `exist_ok` mode. `CREATE` and `OVERWRITE` are
unchanged.
- Upgrade: a standalone Lance REST server from an older release still sends
`EXIST_OK`, so its `exist_ok` requests fail with 400 against an upgraded
Gravitino server. Upgrade the standalone Lance REST server together with the
Gravitino server. Aux-mode Lance REST is not affected.
- In standalone mode, the new load runs as the configured backend identity.
If that identity cannot load an existing table, `exist_ok` on that table now
returns 403 instead of 200.
- `exist_ok` now emits a load-table event, plus create-table events when it
creates the table. Before, it always emitted create-table events. Loading may
also refresh the stored schema of a declared or empty table, the same as
`DescribeTable` and `TableExists`.
Known limits, not changed by this PR:
- `exist_ok` still returns the existing table's metadata to a caller with
only CREATE_TABLE. That is #12955.
- `OVERWRITE` through the Gravitino `createTable` API needs only
CREATE_TABLE. That is #14902, planned for a 2.0.x release.
- A rejected `EXIST_OK` request is checked after the table location is
provisioned. With an allocating location provider, that location stays unused.
### How was this patch tested?
- New unit tests in `TestGravitinoLanceTableOperations`: an existing table
is returned without `createTable`; a missing table is created with `CREATE`; a
concurrent create is loaded and returned; a conflict whose table is gone again
is reported; an existing non-Lance table is rejected.
- `TestLanceTableOperations`: `EXIST_OK` is rejected before any store or
dataset access, for create and register.
- New ITs in `LanceTableAuthorizationIT`:
- A CREATE_TABLE-only user sends `exist_ok` for an admin-owned table. The
owner stays admin, the user still gets 403 on describe and drop, and the
dataset is kept.
- `exist_ok` for a missing table makes the caller the owner.
- Updated `CatalogGenericCatalogLanceIT` for the rejection.
- Without the fix, the existing-owner IT fails with `expected:
<lance_table_authz_admin> but was: <lance_table_authz_prober>`.
- Passed: `TestLanceTableOperations` (100),
`TestGravitinoLanceTableOperations` (17), `TestGravitinoLanceModeParsing` (10),
`LanceTableAuthorizationIT` (16), `LanceRESTServiceIT` (17),
`LanceFormatBoundaryIT` (1), `CatalogGenericCatalogLanceIT` (18).
--
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]