vishnuprakaz commented on code in PR #17437:
URL: https://github.com/apache/iceberg/pull/17437#discussion_r3729035765
##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/TableSerializerCache.java:
##########
@@ -120,9 +126,18 @@ private class SerializerInfo {
}
private void update() {
- Table table =
catalogLoader.loadCatalog().loadTable(TableIdentifier.parse(tableName));
- schemas = table.schemas();
- specs = table.specs();
+ // The serializer has no teardown hook, so a catalog cannot be held for
reuse; load and
+ // close one per cache miss.
+ try (TableLoader tableLoader =
+ TableLoader.fromCatalog(catalogLoader,
TableIdentifier.parse(tableName))) {
+ tableLoader.open();
+ Table table = tableLoader.loadTable();
+ schemas = table.schemas();
+ specs = table.specs();
+ } catch (IOException e) {
+ // only close() throws IOException here; a failed close should not
fail the lookup
+ LOG.warn("Failed to close catalog for table {}", tableName, e);
+ }
Review Comment:
That makes a lot of sense, loading once and reusing is better trade
actually. I was thinking per table and missed how many tables the dynamic sink
could be routing. Made the changes, happy to adjust if anything looks off :)
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]