Skip to content

Commit 23634cc

Browse files
committed
fix sql-tester
Signed-off-by: gengjun-git <gengjun@starrocks.com>
1 parent f48426c commit 23634cc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,6 +3407,13 @@ public void handleDMLStmt(ExecPlan execPlan, DmlStmt stmt) throws Exception {
34073407
LOG.warn("errors when cancel insert load job {}", jobId);
34083408
}
34093409
} else if (txnState != null) {
3410+
// Re-fetch txnState after commit because the COW pattern in DatabaseTransactionMgr
3411+
// replaces the in-memory state with a deep copy, making the original reference stale.
3412+
TransactionState freshTxnState = transactionMgr.getTransactionState(
3413+
database.getId(), transactionId);
3414+
if (freshTxnState != null) {
3415+
txnState = freshTxnState;
3416+
}
34103417
GlobalStateMgr.getCurrentState().getOperationListenerBus()
34113418
.onDMLStmtJobTransactionFinish(txnState, database, targetTable, dmlType);
34123419
}

fe/fe-core/src/main/java/com/starrocks/transaction/TransactionStmtExecutor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,13 @@ public static void commitStmt(ConnectContext context, CommitStmt stmt) {
294294
txnCommitAttachment,
295295
timeout);
296296

297+
// Re-fetch transactionState after commit because the COW pattern in DatabaseTransactionMgr
298+
// replaces the in-memory state with a deep copy, making the original reference stale.
299+
TransactionState freshTxnState = transactionMgr.getTransactionState(databaseId, transactionId);
300+
if (freshTxnState != null) {
301+
transactionState = freshTxnState;
302+
}
303+
297304
long publishWaitMs = Config.enable_sync_publish ? jobDeadLineMs - System.currentTimeMillis() :
298305
context.getSessionVariable().getTransactionVisibleWaitTimeout() * 1000;
299306

0 commit comments

Comments
 (0)