[fix](group commit) abort txn should use label if replay wal failed (#30219)

This commit is contained in:
meiyi
2024-01-22 20:33:00 +08:00
committed by yiguolei
parent 9e0c518aaf
commit 9c742d46a2
6 changed files with 44 additions and 35 deletions

View File

@ -1663,15 +1663,23 @@ public class FrontendServiceImpl implements FrontendService.Iface {
throw new MetaNotFoundException("db " + request.getDb() + " does not exist");
}
long dbId = db.getId();
TransactionState transactionState = Env.getCurrentGlobalTransactionMgr()
.getTransactionState(dbId, request.getTxnId());
if (transactionState == null) {
throw new UserException("transaction [" + request.getTxnId() + "] not found");
if (request.getTxnId() != 0) { // txnId is required in thrift
TransactionState transactionState = Env.getCurrentGlobalTransactionMgr()
.getTransactionState(dbId, request.getTxnId());
if (transactionState == null) {
throw new UserException("transaction [" + request.getTxnId() + "] not found");
}
List<Table> tableList = db.getTablesOnIdOrderIfExist(transactionState.getTableIdList());
Env.getCurrentGlobalTransactionMgr().abortTransaction(dbId, request.getTxnId(),
request.isSetReason() ? request.getReason() : "system cancel",
TxnCommitAttachment.fromThrift(request.getTxnCommitAttachment()), tableList);
} else if (request.isSetLabel()) {
Env.getCurrentGlobalTransactionMgr()
.abortTransaction(db.getId(), request.getLabel(),
request.isSetReason() ? request.getReason() : "system cancel");
} else {
throw new UserException("must set txn_id or label");
}
List<Table> tableList = db.getTablesOnIdOrderIfExist(transactionState.getTableIdList());
Env.getCurrentGlobalTransactionMgr().abortTransaction(dbId, request.getTxnId(),
request.isSetReason() ? request.getReason() : "system cancel",
TxnCommitAttachment.fromThrift(request.getTxnCommitAttachment()), tableList);
}
@Override