This is an automated email from the ASF dual-hosted git repository. liaoxin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 96e4e9e5640 [Fix](mow) Multiple table locks should be acquired in order of table ids (#46305) 96e4e9e5640 is described below commit 96e4e9e5640e2f3397de34b143a4990ddb136bb1 Author: Xin Liao <liao...@selectdb.com> AuthorDate: Wed Jan 8 15:04:39 2025 +0800 [Fix](mow) Multiple table locks should be acquired in order of table ids (#46305) Lock acquisition for multiple tables needs to be sorted by table ids, as unordered locking can result in deadlocks. Even though the table list is already sorted when received, we sort it again here as a defensive programming measure to prevent issues from future code modifications. --- .../apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java b/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java index ffe32348bd0..2ff882bcbfc 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java @@ -137,6 +137,7 @@ import java.io.IOException; import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -1167,8 +1168,12 @@ public class CloudGlobalTransactionMgr implements GlobalTransactionMgrIface { } } + // Get tables that require commit lock - only MOW tables need this: + // 1. Filter to keep only OlapTables with MOW enabled + // 2. Sort by table ID to maintain consistent locking order and prevent deadlocks List<Table> mowTableList = tableList.stream() .filter(table -> table instanceof OlapTable && ((OlapTable) table).getEnableUniqueKeyMergeOnWrite()) + .sorted(Comparator.comparingLong(Table::getId)) .collect(Collectors.toList()); increaseWaitingLockCount(mowTableList); if (!MetaLockUtils.tryCommitLockTables(mowTableList, timeoutMillis, TimeUnit.MILLISECONDS)) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org