Copilot commented on code in PR #7539:
URL: https://github.com/apache/texera/pull/7539#discussion_r3762263910


##########
common/workflow-core/src/main/scala/org/apache/texera/amber/core/storage/result/iceberg/IcebergDocument.scala:
##########
@@ -72,7 +72,10 @@ private[storage] class IcebergDocument[T >: Null <: AnyRef](
 
   private val lock = new ReentrantReadWriteLock()
 
-  @transient lazy val catalog: Catalog = 
IcebergCatalogInstance.getInstance(warehouse)
+  // Resolved per use, never held: the catalog cache is bounded and closes 
evicted
+  // entries (#7290), so a pinned reference could outlive its catalog. A 
public def
+  // (not a lazy val) also means a replaced/rebuilt catalog is picked up 
immediately.
+  def catalog: Catalog = IcebergCatalogInstance.getInstance(warehouse)

Review Comment:
   Resolving this accessor on every call makes `clear()` non-atomic: its 
`tableExists` and `dropTable` calls each invoke `catalog`, so a concurrent 
`replaceInstance` can make the existence check run against catalog A and the 
drop run against catalog B. This can silently leave the table in A or delete 
the same identifier from the replacement catalog. Resolve once at the start of 
each logical operation (especially `clear`) and reuse that local catalog; 
replacement should become visible on the next operation, not midway through one.



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

Reply via email to