Skip to content

Commit

Permalink
fix sqlArgumentsList concurrent modification error
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaojialin committed Mar 23, 2020
1 parent 99310d4 commit da1f872
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
private static final int DELETE_SIZE = 50;
private static final String ERROR_PARSING_SQL =
"meet error while parsing SQL to physical plan: {}";
public static Vector<SqlArgument> sqlArgumentsList = new Vector<>();
public static final Vector<SqlArgument> sqlArgumentsList = new Vector<>();

protected Planner processor;
protected IPlanExecutor executor;
Expand Down Expand Up @@ -508,9 +508,11 @@ public TSExecuteStatementResp executeStatement(TSExecuteStatementReq req) {
sessionIdUsernameMap.get(req.getSessionId()));
long endTime = System.currentTimeMillis();
sqlArgument = new SqlArgument(resp, physicalPlan, statement, startTime, endTime);
sqlArgumentsList.add(sqlArgument);
if (sqlArgumentsList.size() > MAX_SIZE) {
sqlArgumentsList.subList(0, DELETE_SIZE).clear();
synchronized (sqlArgumentsList) {
sqlArgumentsList.add(sqlArgument);
if (sqlArgumentsList.size() > MAX_SIZE) {
sqlArgumentsList.subList(0, DELETE_SIZE).clear();
}
}
return resp;
} else {
Expand Down Expand Up @@ -567,9 +569,11 @@ public TSExecuteStatementResp executeQueryStatement(TSExecuteStatementReq req) {
sessionIdUsernameMap.get(req.getSessionId()));
long endTime = System.currentTimeMillis();
sqlArgument = new SqlArgument(resp, physicalPlan, statement, startTime, endTime);
sqlArgumentsList.add(sqlArgument);
if (sqlArgumentsList.size() > MAX_SIZE) {
sqlArgumentsList.subList(0, DELETE_SIZE).clear();
synchronized (sqlArgumentsList) {
sqlArgumentsList.add(sqlArgument);
if (sqlArgumentsList.size() > MAX_SIZE) {
sqlArgumentsList.subList(0, DELETE_SIZE).clear();
}
}
return resp;
} catch (ParseCancellationException e) {
Expand Down

0 comments on commit da1f872

Please sign in to comment.