Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down