From 2209f45761391e19349620ac3dcea1dcf6d4f9fd Mon Sep 17 00:00:00 2001 From: lihangyu Date: Mon, 18 Nov 2024 10:36:31 +0800 Subject: [PATCH] [Opt](ShortCircuit) opt some serialization and fix error when prepared statment excute failed (#43974) 1. If execute failed in ExecuteCommand run method, then `needAnalyze` should be true, in case that the shortCircuitQueryContext is null 2. Optimization on serialization fields to client 3. The grpcThreadPool should be static to avoid too many thread pools and better metrics view --- .../nereids/trees/plans/commands/ExecuteCommand.java | 8 +++++--- .../java/org/apache/doris/rpc/BackendServiceProxy.java | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ExecuteCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ExecuteCommand.java index d5260a72cde650..91e7532e3c9157 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ExecuteCommand.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ExecuteCommand.java @@ -71,10 +71,12 @@ public void run(ConnectContext ctx, StmtExecutor executor) throws Exception { executor.setParsedStmt(planAdapter); // If it's not a short circuit query or schema version is different(indicates schema changed), // need to do reanalyze and plan - boolean needAnalyze = !executor.getContext().getStatementContext().isShortCircuitQuery() - || (preparedStmtCtx.shortCircuitQueryContext.isPresent() + boolean isShortCircuit = executor.getContext().getStatementContext().isShortCircuitQuery(); + boolean hasShortCircuitContext = preparedStmtCtx.shortCircuitQueryContext.isPresent(); + boolean schemaVersionMismatch = hasShortCircuitContext && preparedStmtCtx.shortCircuitQueryContext.get().tbl.getBaseSchemaVersion() - != preparedStmtCtx.shortCircuitQueryContext.get().schemaVersion); + != preparedStmtCtx.shortCircuitQueryContext.get().schemaVersion; + boolean needAnalyze = !isShortCircuit || schemaVersionMismatch || !hasShortCircuitContext; if (needAnalyze) { // execute real statement preparedStmtCtx.shortCircuitQueryContext = Optional.empty(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/rpc/BackendServiceProxy.java b/fe/fe-core/src/main/java/org/apache/doris/rpc/BackendServiceProxy.java index 830e7da1a7f469..2b725f434b40b3 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/rpc/BackendServiceProxy.java +++ b/fe/fe-core/src/main/java/org/apache/doris/rpc/BackendServiceProxy.java @@ -58,8 +58,10 @@ public class BackendServiceProxy { // use concurrent map to allow access serviceMap in multi thread. private ReentrantLock lock = new ReentrantLock(); - private Executor grpcThreadPool = ThreadPoolManager.newDaemonCacheThreadPool(Config.grpc_threadmgr_threads_nums, + private static Executor grpcThreadPool = ThreadPoolManager.newDaemonCacheThreadPool( + Config.grpc_threadmgr_threads_nums, "grpc_thread_pool", true); + private final Map serviceMap; public BackendServiceProxy() {