This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new 09c747556be branch-4.0: [fix](sql cache) fix 
enable_strong_consistency_read for sql cache #60012 (#60047)
09c747556be is described below

commit 09c747556be8a6b2e1d9c60d53b638fff247f4af
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Jan 20 16:21:24 2026 +0800

    branch-4.0: [fix](sql cache) fix enable_strong_consistency_read for sql 
cache #60012 (#60047)
    
    Cherry-picked from #60012
    
    Co-authored-by: 924060929 <[email protected]>
---
 .../org/apache/doris/common/cache/NereidsSqlCacheManager.java     | 8 ++++++++
 fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java    | 7 ++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/common/cache/NereidsSqlCacheManager.java
 
b/fe/fe-core/src/main/java/org/apache/doris/common/cache/NereidsSqlCacheManager.java
index 665c37f8e7c..fe8f01b7254 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/common/cache/NereidsSqlCacheManager.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/common/cache/NereidsSqlCacheManager.java
@@ -64,6 +64,7 @@ import org.apache.doris.proto.Types.PUniqueId;
 import org.apache.doris.qe.ConnectContext;
 import org.apache.doris.qe.ResultSet;
 import org.apache.doris.qe.SessionVariable;
+import org.apache.doris.qe.StmtExecutor;
 import org.apache.doris.qe.cache.CacheAnalyzer;
 import org.apache.doris.qe.cache.SqlCache;
 import org.apache.doris.rpc.RpcException;
@@ -280,6 +281,13 @@ public class NereidsSqlCacheManager {
             return Optional.empty();
         }
 
+        try {
+            StmtExecutor.syncJournalIfNeeded(connectContext);
+        } catch (Throwable t) {
+            LOG.warn("syncJournalIfNeeded failed", t);
+            return invalidateCache(key);
+        }
+
         // LOG.info("Total size: " + 
GraphLayout.parseInstance(sqlCacheContext).totalSize());
         UserIdentity currentUserIdentity = 
connectContext.getCurrentUserIdentity();
         List<Variable> currentVariables = 
resolveUserVariables(sqlCacheContext);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
index b9c5c2d72f5..71646ac6bc7 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -678,7 +678,7 @@ public class StmtExecutor {
             // t1: client issues create table to master fe
             // t2: client issues query sql to observer fe, the query would 
fail due to not exist table in plan phase.
             // t3: observer fe receive editlog creating the table from the 
master fe
-            syncJournalIfNeeded();
+            syncJournalIfNeeded(context);
             try {
                 ((Command) logicalPlan).verifyCommandSupported(context);
                 ((Command) logicalPlan).run(context, this);
@@ -741,7 +741,7 @@ public class StmtExecutor {
             // t2: client issues query sql to observer fe, the query would 
fail due to not exist table in
             //     plan phase.
             // t3: observer fe receive editlog creating the table from the 
master fe
-            syncJournalIfNeeded();
+            syncJournalIfNeeded(context);
             planner = new NereidsPlanner(statementContext);
             try {
                 checkBlockRulesByRegex(originStmt);
@@ -978,7 +978,8 @@ public class StmtExecutor {
         }
     }
 
-    private void syncJournalIfNeeded() throws Exception {
+    /** syncJournalIfNeeded */
+    public static void syncJournalIfNeeded(ConnectContext context) throws 
Exception {
         final Env env = context.getEnv();
         if (env.isMaster() || 
!context.getSessionVariable().enableStrongConsistencyRead) {
             return;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to