Skip to content

Commit

Permalink
[Enhancement] abort transaction without database lock (#34790)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Zhu <zhuming9011@gmail.com>
(cherry picked from commit 50447b1)
  • Loading branch information
sduzh authored and mergify[bot] committed Nov 10, 2023
1 parent 05425b4 commit 1764aac
Showing 1 changed file with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1238,24 +1238,15 @@ public void abortTransaction(long transactionId, boolean abortPrepared, String r
if (db == null) {
return;
}
List<TransactionStateListener> listeners = Lists.newArrayListWithCapacity(transactionState.getTableIdList().size());
db.readLock();
try {
for (Long tableId : transactionState.getTableIdList()) {
Table table = db.getTable(tableId);
if (table != null) {
TransactionStateListener listener = stateListenerFactory.create(this, table);
if (listener != null) {
listeners.add(listener);
}
}
for (Long tableId : transactionState.getTableIdList()) {
Table table = db.getTable(tableId);
if (table == null) {
continue;
}
TransactionStateListener listener = stateListenerFactory.create(this, table);
if (listener != null) {
listener.postAbort(transactionState, failedTablets);
}
} finally {
db.readUnlock();
}

for (TransactionStateListener listener : listeners) {
listener.postAbort(transactionState, failedTablets);
}
}

Expand Down

0 comments on commit 1764aac

Please sign in to comment.