Skip to content

Commit

Permalink
edit
Browse files Browse the repository at this point in the history
  • Loading branch information
hust-hhb committed Sep 14, 2024
1 parent 0cbe9fd commit 6880357
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public class CloudGlobalTransactionMgr implements GlobalTransactionMgrIface {

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

public CloudGlobalTransactionMgr() {
this.callbackFactory = new TxnStateCallbackFactory();
Expand Down Expand Up @@ -965,7 +965,7 @@ public boolean commitAndPublishTransaction(DatabaseIf db, List<Table> tableList,
long tableId = tableList.get(i).getId();
LOG.info("start commit txn=" + transactionId + ",table=" + tableId);
}
for (Map.Entry<Long, AtomicInteger> entry : countMap.entrySet()) {
for (Map.Entry<Long, AtomicInteger> entry : waitToCommitTxnCountMap.entrySet()) {
if (entry.getValue().get() > 5) {
LOG.info("now table {} commitAndPublishTransaction queue is {}", entry.getKey(),
entry.getValue().get());
Expand Down Expand Up @@ -1740,19 +1740,19 @@ public TransactionState abortSubTxn(long txnId, long subTxnId, long dbId, Set<Lo
private void increaseCount(List<Table> tableList) {
for (int i = 0; i < tableList.size(); i++) {
long tableId = tableList.get(i).getId();
if (countMap.containsKey(tableId)) {
countMap.get(tableId).addAndGet(1);
if (waitToCommitTxnCountMap.containsKey(tableId)) {
waitToCommitTxnCountMap.get(tableId).addAndGet(1);
} else {
countMap.put(tableId, new AtomicInteger());
countMap.get(tableId).addAndGet(1);
waitToCommitTxnCountMap.put(tableId, new AtomicInteger());
waitToCommitTxnCountMap.get(tableId).addAndGet(1);
}
}
}

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

0 comments on commit 6880357

Please sign in to comment.