diff --git a/src/main/java/com/actiontech/dble/net/connection/AbstractConnection.java b/src/main/java/com/actiontech/dble/net/connection/AbstractConnection.java index 5603f1f287..f1294973e1 100644 --- a/src/main/java/com/actiontech/dble/net/connection/AbstractConnection.java +++ b/src/main/java/com/actiontech/dble/net/connection/AbstractConnection.java @@ -170,7 +170,9 @@ public synchronized void closeImmediately(final String reason) { private void closeImmediatelyInner(String reason) { if (isClosed.compareAndSet(false, true)) { if (service instanceof BusinessService) { - ((BusinessService) service).controlTx(TransactionOperate.QUIT); + BusinessService bService = (BusinessService) service; + bService.addHisQueriesCount(); + bService.controlTx(TransactionOperate.QUIT); AbstractTrackProbe.trace(service, t -> t.setExit()); } FrontActiveRatioStat.getInstance().remove(this); diff --git a/src/main/java/com/actiontech/dble/services/BusinessService.java b/src/main/java/com/actiontech/dble/services/BusinessService.java index d340e37517..e8746efe6b 100644 --- a/src/main/java/com/actiontech/dble/services/BusinessService.java +++ b/src/main/java/com/actiontech/dble/services/BusinessService.java @@ -13,6 +13,7 @@ import com.actiontech.dble.net.mysql.EOFPacket; import com.actiontech.dble.net.service.AuthResultInfo; import com.actiontech.dble.server.variables.MysqlVariable; +import com.actiontech.dble.singleton.TsQueriesCounter; import com.actiontech.dble.statistic.CommandCount; import java.util.concurrent.atomic.AtomicLong; @@ -49,6 +50,10 @@ public void resetCounter() { queriesCounter.set(Long.MIN_VALUE); } + public void addHisQueriesCount() { + TsQueriesCounter.getInstance().addToHistory(this); + } + public void executeContextSetTask(MysqlVariable[] contextTask) { MysqlVariable autocommitItem = null; for (MysqlVariable variable : contextTask) { diff --git a/src/main/java/com/actiontech/dble/services/mysqlsharding/ShardingService.java b/src/main/java/com/actiontech/dble/services/mysqlsharding/ShardingService.java index 704e4d7a49..03f9ad4fbb 100644 --- a/src/main/java/com/actiontech/dble/services/mysqlsharding/ShardingService.java +++ b/src/main/java/com/actiontech/dble/services/mysqlsharding/ShardingService.java @@ -41,7 +41,6 @@ import com.actiontech.dble.services.mysqlauthenticate.MySQLChangeUserService; import com.actiontech.dble.singleton.SerializableLock; import com.actiontech.dble.singleton.TraceManager; -import com.actiontech.dble.singleton.TsQueriesCounter; import com.actiontech.dble.util.SplitUtil; import com.actiontech.dble.util.exception.NeedDelayedException; import com.alibaba.druid.wall.WallCheckResult; @@ -573,7 +572,6 @@ public void multiStatementNextSql(boolean flag) { @Override public void cleanup() { super.cleanup(); - TsQueriesCounter.getInstance().addToHistory(this); session.terminate(); if (getLoadDataInfileHandler() != null) { getLoadDataInfileHandler().clear(); diff --git a/src/main/java/com/actiontech/dble/services/rwsplit/RWSplitService.java b/src/main/java/com/actiontech/dble/services/rwsplit/RWSplitService.java index 42bad8f06b..9894b9ca51 100644 --- a/src/main/java/com/actiontech/dble/services/rwsplit/RWSplitService.java +++ b/src/main/java/com/actiontech/dble/services/rwsplit/RWSplitService.java @@ -34,7 +34,6 @@ import com.actiontech.dble.services.mysqlauthenticate.MySQLChangeUserService; import com.actiontech.dble.services.rwsplit.handle.PreparedStatementHolder; import com.actiontech.dble.singleton.TraceManager; -import com.actiontech.dble.singleton.TsQueriesCounter; import com.alibaba.druid.wall.WallCheckResult; import com.alibaba.druid.wall.WallProvider; import org.jetbrains.annotations.NotNull; @@ -465,7 +464,6 @@ public void resetConnection() { public void cleanup() { super.cleanup(); if (session != null) { - TsQueriesCounter.getInstance().addToHistory(this); session.close("clean up"); } }