Repository navigation
[Server] List Iceberg tables without resolving each one again - #1799
Conversation
|
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]>
4b799bb to
551654b
Compare
|
Rebased onto The bug is still there after #1696: Two things changed in the rebase:
|
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( |
There was a problem hiding this comment.
getTableUniformMetadataLocation is no longer used by any code. You can remove it from tableRepository
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Instead of adding to tables, it's better to add directly to ListTablesResponse.builder.
There was a problem hiding this comment.
Done; the loop adds straight into ListTablesResponse.builder(), so the intermediate list is gone.
| } | ||
|
|
||
| @Test | ||
| public void testListTablesToleratesATableDroppedWhileListing() throws Exception { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
PR Checklist
docsis updatedDescription of changes
Fixes #1798.
listTableson 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
findTableOrThrowraiseTABLE_NOT_FOUNDand the endpoint answered 404 -- naming atable the client never asked about -- instead of listing the schema.
TableRepository.listUniformIcebergTablesnow reports which tables of a page are uniform from thevery 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:
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.
testListTablesToleratesATableDroppedWhileListingdrives 200 listings while a table is created anddropped alongside them. It fails on
main(the sixth listing came back 404 in my run) and passes withthis change. The rest of
IcebergRestCatalogTestpasses unchanged, as do the table CRUD suites.