Skip to content
Merged
Show file tree
Hide file tree
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 @@ -505,7 +505,17 @@ private void commitTransaction(long dbId, List<Table> tableList, long transactio
}

final CommitTxnRequest commitTxnRequest = builder.build();
commitTxn(commitTxnRequest, transactionId, is2PC, dbId, tableList);
try {
commitTxn(commitTxnRequest, transactionId, is2PC, dbId, tableList);
} catch (UserException e) {
// For routine load, it is necessary to release the write lock when commit transaction fails,
// otherwise it will cause the lock added in beforeCommitted to not be released.
if (txnCommitAttachment != null && txnCommitAttachment instanceof RLTaskTxnCommitAttachment) {
RLTaskTxnCommitAttachment rlTaskTxnCommitAttachment = (RLTaskTxnCommitAttachment) txnCommitAttachment;
Env.getCurrentEnv().getRoutineLoadManager().getJob(rlTaskTxnCommitAttachment.getJobId()).writeUnlock();
}
throw e;
}
}

private void commitTxn(CommitTxnRequest commitTxnRequest, long transactionId, boolean is2PC, long dbId,
Expand Down Expand Up @@ -1021,6 +1031,12 @@ public void abortTransaction(Long dbId, Long transactionId, String reason,
Preconditions.checkNotNull(abortTxnResponse.getStatus());
} catch (RpcException e) {
LOG.warn("abortTxn failed, transactionId:{}, Exception", transactionId, e);
// For routine load, it is necessary to release the write lock when abort transaction fails,
// otherwise it will cause the lock added in beforeAborted to not be released.
if (txnCommitAttachment != null && txnCommitAttachment instanceof RLTaskTxnCommitAttachment) {
RLTaskTxnCommitAttachment rlTaskTxnCommitAttachment = (RLTaskTxnCommitAttachment) txnCommitAttachment;
Env.getCurrentEnv().getRoutineLoadManager().getJob(rlTaskTxnCommitAttachment.getJobId()).writeUnlock();
}
throw new UserException("abortTxn failed, errMsg:" + e.getMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ protected void writeLock() {
lock.writeLock().lock();
}

protected void writeUnlock() {
public void writeUnlock() {
lock.writeLock().unlock();
}

Expand Down