diff --git a/fe/fe-core/src/main/java/com/starrocks/transaction/DatabaseTransactionMgr.java b/fe/fe-core/src/main/java/com/starrocks/transaction/DatabaseTransactionMgr.java index 8ce2f13a60c8e..da88943d3f5d2 100644 --- a/fe/fe-core/src/main/java/com/starrocks/transaction/DatabaseTransactionMgr.java +++ b/fe/fe-core/src/main/java/com/starrocks/transaction/DatabaseTransactionMgr.java @@ -1207,6 +1207,7 @@ public void finishTransaction(long transactionId, Set errorReplicaIds) thr finishSpan.end(); } + resetTransactionStateTabletCommitInfos(transactionState); transactionState.notifyVisible(); // do after transaction finish GlobalStateMgr.getCurrentState().getOperationListenerBus().onStreamJobTransactionFinish(transactionState); @@ -1907,6 +1908,7 @@ public void finishTransactionNew(TransactionState transactionState, Set pu finishSpan.end(); } + resetTransactionStateTabletCommitInfos(transactionState); // do after transaction finish GlobalStateMgr.getCurrentState().getOperationListenerBus().onStreamJobTransactionFinish(transactionState); GlobalStateMgr.getCurrentState().getLocalMetastore().handleMVRepair(transactionState); @@ -2068,4 +2070,13 @@ public List getSamplesForMemoryTracker() { readUnlock(); } } + + public void resetTransactionStateTabletCommitInfos(TransactionState transactionState) { + writeLock(); + try { + transactionState.resetTabletCommitInfos(); + } finally { + writeUnlock(); + } + } } diff --git a/fe/fe-core/src/main/java/com/starrocks/transaction/TransactionState.java b/fe/fe-core/src/main/java/com/starrocks/transaction/TransactionState.java index 6f1490815755a..75e4d816d86b2 100644 --- a/fe/fe-core/src/main/java/com/starrocks/transaction/TransactionState.java +++ b/fe/fe-core/src/main/java/com/starrocks/transaction/TransactionState.java @@ -427,6 +427,12 @@ public void setTabletCommitInfos(List infos) { this.tabletCommitInfos.addAll(infos); } + public void resetTabletCommitInfos() { + // With a high streamload frequency and too many tablets involved, + // TabletCommitInfos will take up too much memory. + tabletCommitInfos = null; + } + public boolean tabletCommitInfosContainsReplica(long tabletId, long backendId, ReplicaState state) { TabletCommitInfo info = new TabletCommitInfo(tabletId, backendId); if (this.tabletCommitInfos == null) {