donPain commented on code in PR #16044:
URL: https://github.com/apache/iceberg/pull/16044#discussion_r3185145693


##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/TableSerializerCache.java:
##########
@@ -120,9 +134,14 @@ private class SerializerInfo {
     }
 
     private void update() {
-      Table table = 
catalogLoader.loadCatalog().loadTable(TableIdentifier.parse(tableName));
-      schemas = table.schemas();
-      specs = table.specs();
+      Catalog loadedCatalog = catalogLoader.loadCatalog();
+      try {
+        Table table = 
loadedCatalog.loadTable(TableIdentifier.parse(tableName));
+        schemas = table.schemas();
+        specs = table.specs();
+      } finally {
+        closeCatalog(loadedCatalog);

Review Comment:
   I think this is a reasonable trade-off here. TableSerializerCache is used 
from a TypeSerializer, which doesn't really give us a clean lifecycle to keep a 
Catalog open and close it later. Because of that, closing the catalog right 
after the
     lookup feels safer.
   
     We still have caching where it matters: once the schema/spec ids are 
resolved, the schemas, specs, and RowDataSerializer are cached, so we don't 
open/close the catalog on the normal hot path. Adding a catalog cache here 
would only help on cache misses, but it would also make resource cleanup harder 
and increase the risk of leaks.



-- 
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]

Reply via email to