aiborodin commented on code in PR #14792:
URL: https://github.com/apache/iceberg/pull/14792#discussion_r2609536835


##########
flink/v2.0/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/TableMetadataCache.java:
##########
@@ -207,9 +207,26 @@ private Tuple2<Boolean, Exception> 
refreshTable(TableIdentifier identifier) {
   }
 
   private boolean needsRefresh(CacheItem cacheItem, boolean allowRefresh) {
-    return allowRefresh
-        && (cacheItem == null
-            || cacheRefreshClock.millis() - cacheItem.createdTimestampMillis > 
refreshMs);
+    if (!allowRefresh) {
+      return false;
+    }
+
+    if (cacheItem == null) {
+      return true;
+    }
+
+    long nowMillis = cacheRefreshClock.millis();
+    long timeElapsedMillis = nowMillis - cacheItem.createdTimestampMillis;
+    if (timeElapsedMillis > refreshMs) {
+      LOG.info(

Review Comment:
   > I just realized you only added logging for cache misses when the cache is 
already populated, I think that may be fine. Cache misses should only occur on 
schema changes.
   
   Exactly.



##########
flink/v2.0/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/TableMetadataCache.java:
##########
@@ -78,8 +78,8 @@ Tuple2<Boolean, Exception> exists(TableIdentifier identifier) 
{
     CacheItem cached = tableCache.get(identifier);
     if (cached != null && Boolean.TRUE.equals(cached.tableExists)) {
       return EXISTS;
-    } else if (needsRefresh(cached, true)) {
-      return refreshTable(identifier);
+    } else if (maybeRefreshTable(identifier, cached, true)) {
+      return EXISTS;

Review Comment:
   I'll raise a separate review with the reasoning to keep this change simple.
   I reverted this to the existing solution for now.



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