diff --git a/fe/fe-core/src/main/java/org/apache/doris/http/action/SystemAction.java b/fe/fe-core/src/main/java/org/apache/doris/http/action/SystemAction.java index ae25e4e4268d8f..72b956c1460b81 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/http/action/SystemAction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/http/action/SystemAction.java @@ -89,7 +89,7 @@ private void appendSystemInfo(StringBuilder buffer, String procPath, String path // forward to master String showProcStmt = "SHOW PROC \"" + procPath + "\""; MasterOpExecutor masterOpExecutor = new MasterOpExecutor(new OriginStatement(showProcStmt, 0), - ConnectContext.get(), RedirectStatus.FORWARD_NO_SYNC); + ConnectContext.get(), RedirectStatus.FORWARD_NO_SYNC, true); try { masterOpExecutor.execute(); } catch (Exception e) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/http/rest/ShowProcAction.java b/fe/fe-core/src/main/java/org/apache/doris/http/rest/ShowProcAction.java index c00ade61440d91..bb53d9c7e7b3b5 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/http/rest/ShowProcAction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/http/rest/ShowProcAction.java @@ -79,7 +79,7 @@ public void executeWithoutPassword(BaseRequest request, BaseResponse response) t context.setQualifiedUser(ConnectContext.get().getQualifiedUser()); context.setRemoteIP(ConnectContext.get().getRemoteIP()); MasterOpExecutor masterOpExecutor = new MasterOpExecutor(new OriginStatement(showProcStmt, 0), context, - RedirectStatus.FORWARD_NO_SYNC); + RedirectStatus.FORWARD_NO_SYNC, true); LOG.debug("need to transfer to Master. stmt: {}", context.getStmtId()); try { diff --git a/fe/fe-core/src/main/java/org/apache/doris/httpv2/controller/SystemController.java b/fe/fe-core/src/main/java/org/apache/doris/httpv2/controller/SystemController.java index 0d2efb59571572..02603c59c22372 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/controller/SystemController.java +++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/controller/SystemController.java @@ -104,7 +104,7 @@ private ResponseEntity appendSystemInfo(String procPath, String path, HttpServle String showProcStmt = "SHOW PROC \"" + procPath + "\""; MasterOpExecutor masterOpExecutor = new MasterOpExecutor(new OriginStatement(showProcStmt, 0), - ConnectContext.get(), RedirectStatus.FORWARD_NO_SYNC); + ConnectContext.get(), RedirectStatus.FORWARD_NO_SYNC, true); try { masterOpExecutor.execute(); } catch (Exception e) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java index a9e502950ac773..890aa8fdf9ecfb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java @@ -42,7 +42,9 @@ public class MasterOpExecutor { // the total time of thrift connectTime add readTime and writeTime private int thriftTimeoutMs; - public MasterOpExecutor(OriginStatement originStmt, ConnectContext ctx, RedirectStatus status) { + private boolean shouldNotRetry; + + public MasterOpExecutor(OriginStatement originStmt, ConnectContext ctx, RedirectStatus status, boolean isQuery) { this.originStmt = originStmt; this.ctx = ctx; if (status.isNeedToWaitJournalSync()) { @@ -51,6 +53,8 @@ public MasterOpExecutor(OriginStatement originStmt, ConnectContext ctx, Redirect this.waitTimeoutMs = 0; } this.thriftTimeoutMs = ctx.getSessionVariable().getQueryTimeoutS() * 1000; + // if isQuery=false, we shouldn't retry twice when catch exception because of Idempotency + this.shouldNotRetry = !isQuery; } public void execute() throws Exception { @@ -103,7 +107,7 @@ private void forward() throws Exception { if (!ok) { throw e; } - if (e.getType() == TTransportException.TIMED_OUT) { + if (shouldNotRetry || e.getType() == TTransportException.TIMED_OUT) { throw e; } else { result = client.forward(params); 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 6cd135faa009ed..1f1e96b98d42c9 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 @@ -359,7 +359,8 @@ public void execute() throws Exception { } private void forwardToMaster() throws Exception { - masterOpExecutor = new MasterOpExecutor(originStmt, context, redirectStatus); + boolean isQuery = parsedStmt instanceof QueryStmt; + masterOpExecutor = new MasterOpExecutor(originStmt, context, redirectStatus, isQuery); LOG.debug("need to transfer to Master. stmt: {}", context.getStmtId()); masterOpExecutor.execute(); }