Skip to content

Commit

Permalink
[inner-2194] fix: questions and transactions occasionally appear as 0
Browse files Browse the repository at this point in the history
  • Loading branch information
wenyh1 committed Oct 8, 2023
1 parent a6c5007 commit e594c60
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -465,7 +464,6 @@ public void resetConnection() {
public void cleanup() {
super.cleanup();
if (session != null) {
TsQueriesCounter.getInstance().addToHistory(this);
session.close("clean up");
}
}
Expand Down

0 comments on commit e594c60

Please sign in to comment.