yujun777 commented on code in PR #63470:
URL: https://github.com/apache/doris/pull/63470#discussion_r3310366396


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalRowCountCache.java:
##########
@@ -83,40 +83,49 @@ public int hashCode() {
     public static class RowCountCacheLoader extends 
BasicAsyncCacheLoader<RowCountKey, Optional<Long>> {
         @Override
         protected Optional<Long> doLoad(RowCountKey rowCountKey) {
-            try {
-                TableIf table = 
StatisticsUtil.findTable(rowCountKey.catalogId, rowCountKey.dbId, 
rowCountKey.tableId);
-                return Optional.of(table.fetchRowCount());
-            } catch (Exception e) {
-                String message = String.format("Failed to get table row count 
with catalogId %s, dbId %s, tableId %s. "
-                                + "Reason %s",
-                        rowCountKey.catalogId, rowCountKey.dbId, 
rowCountKey.tableId, e.getMessage());
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug(message, e);
-                } else {
-                    LOG.warn(message);
-                }
+            return loadRowCount(rowCountKey, false);
+        }
+    }
 
-                // Return Optional.empty() will cache this empty value in 
memory,
-                // so we can't try to load the row count until the cache 
expire.
-                // Throw an exception here will cause too much stack log in 
fe.out.
-                // So we return null when exception happen.
-                // Null may raise NPE in caller, but that is expected.
-                // We catch that NPE and return a default value -1 without 
keep the value in cache,
-                // so we can trigger the load function to fetch row count 
again next time in this exception case.
-                return null;
+    static Optional<Long> loadRowCount(RowCountKey rowCountKey, boolean 
fillMetaCache) {
+        try {
+            ExternalTable table = (ExternalTable) StatisticsUtil.findTable(
+                    rowCountKey.catalogId, rowCountKey.dbId, 
rowCountKey.tableId);
+            return 
Optional.of(table.fetchRowCountWithMetaCache(fillMetaCache));
+        } catch (Exception e) {
+            String message = String.format("Failed to get table row count with 
catalogId %s, dbId %s, tableId %s. "
+                            + "Reason %s",
+                    rowCountKey.catalogId, rowCountKey.dbId, 
rowCountKey.tableId, e.getMessage());
+            if (LOG.isDebugEnabled()) {
+                LOG.debug(message, e);
+            } else {
+                LOG.warn(message);
             }

Review Comment:
   Done. I kept the failure log at WARN level and only made the stack trace 
conditional on debug logging being enabled.



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