Skip to content

[Server] List Iceberg tables without resolving each one again - #1799

Merged
yili-db merged 3 commits into
unitycatalog:mainfrom
moomindani:fix/iceberg-list-tables-race
Sep 9, 2026
Merged

yili-db merged 3 commits into
unitycatalog:mainfrom
moomindani:fix/iceberg-list-tables-race

Conversation

@moomindani

Copy link
Copy Markdown
Contributor

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Fixes #1798.

listTables on the Iceberg REST endpoint listed a schema's tables and then asked the repository,
once per listed table, whether that table carries UniForm Iceberg metadata. That question was
answered by resolving the table by name again, after the page had been read, so a table dropped in
between made findTableOrThrow raise TABLE_NOT_FOUND and the endpoint answered 404 -- naming a
table the client never asked about -- instead of listing the schema.

TableRepository.listUniformIcebergTables now reports which tables of a page are uniform from the
very rows the page was read from, and the endpoint builds its response out of those pages. Nothing is
resolved twice, so a table created or dropped after a page was read cannot affect that page, and a
page costs one query rather than one plus two per table it holds.

Measured against a running server, four threads listing one schema while four more created and
dropped tables in it for 20 seconds:

before after
listings that succeeded 30172 50311
listings that failed with 404 6641 0

The response for a quiet schema is unchanged, and so is paging: the listing still follows the
repository's page token to the end, so a page whose tables are all non-uniform contributes nothing
without ending the walk.

testListTablesToleratesATableDroppedWhileListing drives 200 listings while a table is created and
dropped alongside them. It fails on main (the sixth listing came back 404 in my run) and passes with
this change. The rest of IcebergRestCatalogTest passes unchanged, as do the table CRUD suites.

@yili-db

yili-db commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Please rebase. The conflict was caused by #1696.

The Iceberg listTables endpoint listed a schema's tables and then, for every table it had just
listed, asked the repository whether that table carries UniForm Iceberg metadata. That second
resolution runs after the page was read, so a table dropped in between made the lookup throw
TABLE_NOT_FOUND and the whole listing failed with a 404 naming a table the client never asked about.
Against a server listing one schema while tables were created and dropped alongside it, 6641 of
36813 listings failed this way.

Have the repository report which tables of a page are uniform from the very rows the page was read
from, and build the response out of that. A table created or dropped after a page was read can no
longer affect it, and a page now costs one query instead of one plus two per table it holds: the
same 20-second run answers 50311 listings with none failing.

Signed-off-by: Noritaka Sekiyama <[email protected]>
@moomindani
moomindani force-pushed the fix/iceberg-list-tables-race branch from 4b799bb to 551654b Compare September 5, 2026 12:50
@moomindani

Copy link
Copy Markdown
Contributor Author

Rebased onto 58d5c7b (main).

The bug is still there after #1696: listTables reads a page of the schema's tables and then calls getTableUniformMetadataLocation for each listed name, which goes through findTableOrThrow, so a table dropped between the page read and the filter still fails the whole listing. On 58d5c7b the new test fails with listing 23 returned {"error":{"message":"Table not found: uc_testcatalog.uc_testschema.churned","type":"NoSuchTableException","code":404}} where 200 was expected, and passes with the fix.

Two things changed in the rebase:

  • The repository method is now listIcebergTables returning IcebergTablePage, not listUniformIcebergTables/UniformIcebergTablePage. Implement native Iceberg REST catalog write endpoints #1696 made uniform_iceberg_metadata_location the metadata pointer for native Iceberg tables as well, so the old name no longer described what the predicate selects. The predicate itself is unchanged, and it is the same one listTables applies on main.
  • IcebergRestCatalogService no longer opens a session of its own for this endpoint, so the now-unused sessionFactory field and the two Hibernate imports go with it.

server/testOnly io.unitycatalog.server.service.IcebergRestCatalogTest io.unitycatalog.server.service.IcebergRestCatalogServiceTest is green (10/10 and 4/4).

The All tests job failed on CliTableCRUDTest.testTableCRUD with a JsonMappingException from a closed
stream, which this change does not touch: the same job passes on the sibling PRs off the same base.
This empty commit only re-triggers CI, since re-running the job needs write access to the repository.

Signed-off-by: Noritaka Sekiyama <[email protected]>
.filter(
tableInfo -> {
String metadataLocation =
tableRepository.getTableUniformMetadataLocation(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getTableUniformMetadataLocation is no longer used by any code. You can remove it from tableRepository

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. It existed only for the second resolution this change drops, and nothing else called it.

IcebergTablePage page = tableRepository.listIcebergTables(catalog, namespace, pageToken);
page.tableNames().stream()
.map(tableName -> TableIdentifier.of(Namespace.of(namespace), tableName))
.forEach(tables::add);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding to tables, it's better to add directly to ListTablesResponse.builder.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done; the loop adds straight into ListTablesResponse.builder(), so the intermediate list is gone.

}

@Test
public void testListTablesToleratesATableDroppedWhileListing() throws Exception {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is heavy and non-deterministic. I think it's better to remove it.
Existing test still verifies that the list table functionality is working.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. Fair: it ran 200 listings against a churn thread to hit a window, which is slow and could only ever fail probabilistically.

One thing to flag: with it gone, this PR has no test that fails without the fix. testListTablesReturnsTablesBeyondTheFirstPage covers paging and the uniform filter deterministically, but not the dropped-table window, which cannot be reached without concurrency. The change is structural rather than conditional -- the per-table second resolution is gone, so there is no window left -- and the measurements in the description (6641 of 36813 listings failed before, 0 of 50311 after) stand as the evidence. Happy to add something slimmer if you would rather have a test in the file.

Review follow-up, no behaviour change. The listing collects straight into
ListTablesResponse.builder() rather than into a list first, and
getTableUniformMetadataLocation goes away with the second resolution it existed
for, since nothing else called it.

The concurrency test is removed as asked. It ran 200 listings against a churn
thread to hit the window this change closes, which is slow and could only ever
fail probabilistically; testListTablesReturnsTablesBeyondTheFirstPage still
covers paging and the uniform filter deterministically.

Signed-off-by: Noritaka Sekiyama <[email protected]>
@yili-db
yili-db merged commit c81bb9c into unitycatalog:main Sep 9, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Iceberg REST listTables fails with 404 when a table is dropped while it is listing

2 participants