From 0cbe9fd363773e1611b3356acd2623c31621354e Mon Sep 17 00:00:00 2001 From: huanghaibin <284824253@qq.com> Date: Tue, 3 Sep 2024 22:27:00 +0800 Subject: [PATCH] [improve](cloud-mow) print the queue length of committing txn on FE --- .../CloudGlobalTransactionMgr.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java b/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java index f224d2929a65c1..5affdb7c8c35c8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java @@ -142,6 +142,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; public class CloudGlobalTransactionMgr implements GlobalTransactionMgrIface { @@ -150,6 +151,7 @@ public class CloudGlobalTransactionMgr implements GlobalTransactionMgrIface { private TxnStateCallbackFactory callbackFactory; private final Map subTxnIdToTxnId = new ConcurrentHashMap<>(); + private Map countMap = new ConcurrentHashMap<>(); public CloudGlobalTransactionMgr() { this.callbackFactory = new TxnStateCallbackFactory(); @@ -959,7 +961,19 @@ public boolean commitAndPublishTransaction(DatabaseIf db, long transactionId, public boolean commitAndPublishTransaction(DatabaseIf db, List tableList, long transactionId, List tabletCommitInfos, long timeoutMillis, TxnCommitAttachment txnCommitAttachment) throws UserException { + for (int i = 0; i < tableList.size(); i++) { + long tableId = tableList.get(i).getId(); + LOG.info("start commit txn=" + transactionId + ",table=" + tableId); + } + for (Map.Entry entry : countMap.entrySet()) { + if (entry.getValue().get() > 5) { + LOG.info("now table {} commitAndPublishTransaction queue is {}", entry.getKey(), + entry.getValue().get()); + } + } + increaseCount(tableList); if (!MetaLockUtils.tryCommitLockTables(tableList, timeoutMillis, TimeUnit.MILLISECONDS)) { + decreaseCount(tableList); // DELETE_BITMAP_LOCK_ERR will be retried on be throw new UserException(InternalErrorCode.DELETE_BITMAP_LOCK_ERR, "get table cloud commit lock timeout, tableList=(" @@ -968,6 +982,7 @@ public boolean commitAndPublishTransaction(DatabaseIf db, List
tableList, try { commitTransaction(db.getId(), tableList, transactionId, tabletCommitInfos, txnCommitAttachment); } finally { + decreaseCount(tableList); MetaLockUtils.commitUnlockTables(tableList); } return true; @@ -1721,4 +1736,23 @@ public TransactionState abortSubTxn(long txnId, long subTxnId, long dbId, Set tableList) { + for (int i = 0; i < tableList.size(); i++) { + long tableId = tableList.get(i).getId(); + if (countMap.containsKey(tableId)) { + countMap.get(tableId).addAndGet(1); + } else { + countMap.put(tableId, new AtomicInteger()); + countMap.get(tableId).addAndGet(1); + } + } + } + + private void decreaseCount(List
tableList) { + for (int i = 0; i < tableList.size(); i++) { + long tableId = tableList.get(i).getId(); + countMap.get(tableId).decrementAndGet(); + } + } }