Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve](cloud-mow) print the queue length of committing txn on FE #40340

Merged
merged 3 commits into from
Sep 24, 2024
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 @@ -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 {
Expand All @@ -150,6 +151,7 @@ public class CloudGlobalTransactionMgr implements GlobalTransactionMgrIface {

private TxnStateCallbackFactory callbackFactory;
private final Map<Long, Long> subTxnIdToTxnId = new ConcurrentHashMap<>();
private Map<Long, AtomicInteger> waitToCommitTxnCountMap = new ConcurrentHashMap<>();

public CloudGlobalTransactionMgr() {
this.callbackFactory = new TxnStateCallbackFactory();
Expand Down Expand Up @@ -959,7 +961,19 @@ public boolean commitAndPublishTransaction(DatabaseIf db, long transactionId,
public boolean commitAndPublishTransaction(DatabaseIf db, List<Table> tableList, long transactionId,
List<TabletCommitInfo> 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<Long, AtomicInteger> entry : waitToCommitTxnCountMap.entrySet()) {
if (entry.getValue().get() > 5) {
LOG.info("now table {} commitAndPublishTransaction queue is {}", entry.getKey(),
zhannngchen marked this conversation as resolved.
Show resolved Hide resolved
entry.getValue().get());
}
}
increaseWaitingLockCount(tableList);
if (!MetaLockUtils.tryCommitLockTables(tableList, timeoutMillis, TimeUnit.MILLISECONDS)) {
decreaseWaitingLockCount(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=("
Expand All @@ -968,6 +982,7 @@ public boolean commitAndPublishTransaction(DatabaseIf db, List<Table> tableList,
try {
commitTransaction(db.getId(), tableList, transactionId, tabletCommitInfos, txnCommitAttachment);
} finally {
decreaseWaitingLockCount(tableList);
MetaLockUtils.commitUnlockTables(tableList);
}
return true;
Expand Down Expand Up @@ -1721,4 +1736,23 @@ public TransactionState abortSubTxn(long txnId, long subTxnId, long dbId, Set<Lo
}
return TxnUtil.transactionStateFromPb(response.getTxnInfo());
}

private void increaseWaitingLockCount(List<Table> tableList) {
for (int i = 0; i < tableList.size(); i++) {
long tableId = tableList.get(i).getId();
if (waitToCommitTxnCountMap.containsKey(tableId)) {
waitToCommitTxnCountMap.get(tableId).addAndGet(1);
} else {
waitToCommitTxnCountMap.put(tableId, new AtomicInteger());
waitToCommitTxnCountMap.get(tableId).addAndGet(1);
}
}
}

private void decreaseWaitingLockCount(List<Table> tableList) {
for (int i = 0; i < tableList.size(); i++) {
long tableId = tableList.get(i).getId();
waitToCommitTxnCountMap.get(tableId).decrementAndGet();
}
}
}
Loading