Skip to content
Merged
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 @@ -363,7 +363,14 @@ private boolean executeSQL(String sql) throws TException, SQLException {
execReq.setTimeout((long) queryTimeout * 1000);
TSExecuteStatementResp execResp =
callWithRetryAndReconnect(
() -> client.executeStatementV2(execReq), TSExecuteStatementResp::getStatus);
() -> {
// reConnect() may have replaced the session/statement id, so refresh them on every
// attempt; otherwise the server reports "StatementId doesn't exist in this session".
execReq.setSessionId(sessionId);
execReq.setStatementId(stmtId);
return client.executeStatementV2(execReq);
},
TSExecuteStatementResp::getStatus);

if (execResp.isSetOperationType() && execResp.getOperationType().equals("dropDB")) {
connection.changeDefaultDatabase(null);
Expand Down Expand Up @@ -430,7 +437,13 @@ private int[] executeBatchSQL() throws TException, BatchUpdateException, SQLExce
isCancelled = false;
TSExecuteBatchStatementReq execReq = new TSExecuteBatchStatementReq(sessionId, batchSQLList);
TSStatus execResp =
callWithRetryAndReconnect(() -> client.executeBatchStatement(execReq), status -> status);
callWithRetryAndReconnect(
() -> {
// reConnect() may have replaced the session id, so refresh it on every attempt.
execReq.setSessionId(sessionId);
return client.executeBatchStatement(execReq);
},
status -> status);
int[] result = new int[batchSQLList.size()];
boolean allSuccess = true;
StringBuilder message = new StringBuilder(System.lineSeparator());
Expand Down Expand Up @@ -500,7 +513,14 @@ private ResultSet executeQuerySQL(String sql, long timeoutInMS) throws TExceptio
execReq.setJdbcQuery(true);
TSExecuteStatementResp execResp =
callWithRetryAndReconnect(
() -> client.executeQueryStatementV2(execReq), TSExecuteStatementResp::getStatus);
() -> {
// reConnect() may have replaced the session/statement id, so refresh them on every
// attempt; otherwise the server reports "StatementId doesn't exist in this session".
execReq.setSessionId(sessionId);
execReq.setStatementId(stmtId);
return client.executeQueryStatementV2(execReq);
},
TSExecuteStatementResp::getStatus);
queryId = execResp.getQueryId();
try {
RpcUtils.verifySuccess(execResp.getStatus());
Expand Down Expand Up @@ -575,7 +595,14 @@ private int executeUpdateSQL(final String sql)
final TSExecuteStatementReq execReq = new TSExecuteStatementReq(sessionId, sql, stmtId);
final TSExecuteStatementResp execResp =
callWithRetryAndReconnect(
() -> client.executeUpdateStatement(execReq), TSExecuteStatementResp::getStatus);
() -> {
// reConnect() may have replaced the session/statement id, so refresh them on every
// attempt; otherwise the server reports "StatementId doesn't exist in this session".
execReq.setSessionId(sessionId);
execReq.setStatementId(stmtId);
return client.executeUpdateStatement(execReq);
},
TSExecuteStatementResp::getStatus);
if (execResp.isSetQueryId()) {
queryId = execResp.getQueryId();
}
Expand Down
Loading