wenzhenghu commented on code in PR #64705:
URL: https://github.com/apache/doris/pull/64705#discussion_r3466405026


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/MetaCacheEntry.java:
##########
@@ -155,31 +194,101 @@ public MetaCacheEntryStats stats() {
                 cacheStats.hitCount(),
                 cacheStats.missCount(),
                 cacheStats.hitRate(),
-                cacheStats.loadSuccessCount(),
-                cacheStats.loadFailureCount(),
-                cacheStats.totalLoadTime(),
-                cacheStats.averageLoadPenalty(),
+                successCount,
+                failureCount,
+                totalLoadTime,
+                totalLoadCount == 0 ? 0D : (double) totalLoadTime / 
totalLoadCount,
                 cacheStats.evictionCount(),
                 invalidateCount.get(),
                 lastLoadSuccessTimeMs.get(),
                 lastLoadFailureTimeMs.get(),
                 lastError.get());
     }
 
+    // Read the config dynamically so existing cache entries follow runtime 
config updates.
+    private boolean isManualMissLoadEnabled() {
+        return Config.enable_external_meta_cache_manual_miss_load;
+    }
+
+    // Execute slow miss loads outside Caffeine's sync load path and suppress 
stale write-back after invalidation.
+    private V getWithManualLoad(K key, Function<K, V> loadFunction) {
+        if (!effectiveEnabled) {
+            // Bypass cache entirely when the entry is disabled so manual miss 
load does not relax disable semantics.
+            return loadAndTrack(key, loadFunction);
+        }
+
+        V value = data.getIfPresent(key);
+        if (value != null) {
+            return value;
+        }
+
+        synchronized (loadLock(key)) {
+            value = data.asMap().get(key);
+            if (value != null) {
+                return value;
+            }
+
+            long generation = invalidateGeneration.get();
+            V loaded = loadAndTrack(key, loadFunction);
+            if (generation != invalidateGeneration.get()) {
+                return loaded;
+            }
+
+            // Keep null results uncached so manual miss load matches 
LoadingCache null-return behavior.
+            if (loaded == null) {
+                return null;
+            }
+
+            // Leave a narrow hook for tests to pause exactly before the cache 
put race window.
+            beforeManualCachePutForTest(key, loaded);
+            data.put(key, loaded);
+            if (generation != invalidateGeneration.get()) {

Review Comment:
   This theoretical race has no practical impact on online usage, so I will 
skip the fix for the time being.



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