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>
  • Loading branch information
sduzh authored Nov 10, 2023
1 parent 46e3509 commit 50447b1
Showing 1 changed file with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1322,24 +1322,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 50447b1

Please sign in to comment.