This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new 257e07ae169 branch-2.1: [fix](Nereids) insert lock all target tables #47033 (#47172) 257e07ae169 is described below commit 257e07ae16967142343928666dc8c2710c42f56f Author: morrySnow <zhangwen...@selectdb.com> AuthorDate: Fri Jan 17 20:36:26 2025 +0800 branch-2.1: [fix](Nereids) insert lock all target tables #47033 (#47172) pick from master #47033 --- .../trees/plans/commands/insert/InsertIntoTableCommand.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java index 73455da61d2..82de92251de 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java @@ -24,6 +24,7 @@ import org.apache.doris.catalog.TableIf; import org.apache.doris.common.ErrorCode; import org.apache.doris.common.ErrorReport; import org.apache.doris.common.util.DebugUtil; +import org.apache.doris.common.util.MetaLockUtils; import org.apache.doris.common.util.ProfileManager.ProfileType; import org.apache.doris.datasource.hive.HMSExternalTable; import org.apache.doris.datasource.iceberg.IcebergExternalTable; @@ -58,9 +59,11 @@ import org.apache.doris.qe.StmtExecutor; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; +import com.google.common.collect.Lists; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.Comparator; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -178,7 +181,9 @@ public class InsertIntoTableCommand extends Command implements ForwardWithSync, // lock after plan and check does table's schema changed to ensure we lock table order by id. TableIf newestTargetTableIf = RelationUtil.getTable(qualifiedTargetTableName, ctx.getEnv()); - newestTargetTableIf.readLock(); + List<TableIf> targetTables = Lists.newArrayList(targetTableIf, newestTargetTableIf); + targetTables.sort(Comparator.comparing(TableIf::getId)); + MetaLockUtils.readLockTables(targetTables); try { if (targetTableIf.getId() != newestTargetTableIf.getId()) { LOG.warn("insert plan failed {} times. query id is {}. table id changed from {} to {}", @@ -202,9 +207,9 @@ public class InsertIntoTableCommand extends Command implements ForwardWithSync, buildResult.physicalSink ); } - newestTargetTableIf.readUnlock(); + MetaLockUtils.readUnlockTables(targetTables); } catch (Throwable e) { - newestTargetTableIf.readUnlock(); + MetaLockUtils.readUnlockTables(targetTables); // the abortTxn in onFail need to acquire table write lock if (insertExecutor != null) { insertExecutor.onFail(e); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org