markhoerth opened a new issue, #14303:
URL: https://github.com/apache/gravitino/issues/14303
### Version
main branch (2.0.0-SNAPSHOT, eb988d1)
### Describe what's wrong
`registerTable` with `overwrite: true` swaps the table's metadata location
before it checks that
the new metadata file belongs to the same table. When the file is another
table's metadata, the
swap is committed, the check then fails, and the request returns 500. The
client is told the
request failed while the table now points at the other table's metadata.
In `MetastoreRegisterTableUtils.registerTable`
(`iceberg/iceberg-common/src/main/java/org/apache/iceberg/MetastoreRegisterTableUtils.java`):
- `:87` reads the new metadata file but does not compare its table UUID with
the current one.
- `:90` commits the swap through `metadataLocationOverwrite.overwrite(...)`.
- `:91` calls `metastoreOps.refresh()`, which throws
`IllegalStateException: Table UUID does not match: current=... !=
refreshed=...`.
`IcebergExceptionMapper` has no mapping for `IllegalStateException` and
returns 500.
Problem scenario: an operator restores a table from a backup and picks the
metadata file of a
different table by mistake. The request reports a server error, so the
operator assumes nothing
changed, but readers now see the other table's schema and data. Pointing the
table back with its
own earlier metadata file fails the same way (the UUIDs differ in the other
direction), although
that second swap is also committed.
### Error message and/or stacktrace
```
ERROR IcebergExceptionMapper - Iceberg REST server unexpected failure:
java.lang.IllegalStateException: Table UUID does not match:
current=e4d3fd7a-... != refreshed=7da0939f-...
```
### How to reproduce
1. Create tables `a` and `b` in namespace `ns` through the Iceberg REST
service.
2. `POST /iceberg/v1/namespaces/ns/register` with
`{"name": "a", "metadata-location": "<b's metadata-location>",
"overwrite": true}`.
3. The response is 500. `GET /iceberg/v1/namespaces/ns/tables/a` now returns
b's metadata location.
### Additional context
Requirement: an overwrite whose metadata file has a different table UUID is
refused with a 4xx
before anything is committed, and the table is left as it was. Related:
#11059.
--
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]