github-actions[bot] commented on code in PR #64650:
URL: https://github.com/apache/doris/pull/64650#discussion_r3503221087
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java:
##########
@@ -1833,25 +1838,32 @@ public void addPartition(Database db, String tableName,
AddPartitionOp addPartit
}
if (writeEditLog) {
Env.getCurrentEnv().getEditLog().logAddPartition(info);
+ editLogWritten = true;
if (isTempPartition) {
olapTable.addTempPartition(partition);
} else {
olapTable.addPartition(partition);
}
+ partitionPublished = true;
LOG.info("succeed in creating partition[{}], temp: {}",
partitionId, isTempPartition);
} else {
batchPartitions.add(Pair.of(info, partition));
+ partitionPublished = true;
LOG.info("postpone creating partition[{}], temp: {}",
partitionId, isTempPartition);
}
} finally {
olapTable.writeUnlock();
}
Review Comment:
This rollback still leaves a small inconsistent window.
`handleNewSinglePartitionDesc()` has already inserted the new id into
`PartitionInfo`, but if `afterCreatePartitions()` throws before the edit
log/table publish, the inner `finally` releases the table write lock before
this catch reacquires it to drop that metadata. A concurrent reader can then
see `PartitionInfo` containing the failed id while `olapTable.addPartition()`
has not populated `idToPartition`; for example `RangePartitionInfo.toSql()`
iterates `idToItem` and immediately dereferences
`table.getPartition(id).getName()` for `SHOW CREATE`/DDL generation paths.
Please roll back the just-added `PartitionInfo` entry before releasing the
original table write lock, so the metadata mutation and its rollback remain
atomic to readers.
##########
fe/fe-core/src/test/java/org/apache/doris/clone/DecommissionTest.java:
##########
@@ -151,7 +151,7 @@ public void testDecommissionBackend() throws Exception {
+ " \"replication_num\" = \"1\"\n"
+ ")";
ExceptionChecker.expectThrowsNoException(() -> createTable(createStr));
- int totalReplicaNum = 1 * 2400;
+ int totalReplicaNum = 1 * 64;
Review Comment:
This expectation no longer matches the table being created. The DDL above
still uses `distributed by hash(k2) buckets 2400` with `replication_num = 1`,
and `checkBalance()` compares the actual backend tablet counts from
`Env.getCurrentInvertedIndex().getTabletNumByBackendId()` against
`totalReplicaNum / backendNum`. With 2400 one-replica buckets the average
should be about 600 before decommission and 800 after decommission, not 16/21,
so the test can fail for the wrong reason. Please either restore the expected
total to `1 * 2400` or reduce the bucket count to 64 as well.
##########
fe/fe-core/src/test/java/org/apache/doris/datasource/InternalCatalogTest.java:
##########
@@ -0,0 +1,226 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.datasource;
+
+import org.apache.doris.analysis.PartitionKeyDesc;
+import org.apache.doris.analysis.PartitionValue;
+import org.apache.doris.analysis.SinglePartitionDesc;
+import org.apache.doris.catalog.BinlogConfig;
+import org.apache.doris.catalog.CatalogTestUtil;
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.DataProperty;
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.DiskInfo;
+import org.apache.doris.catalog.DistributionInfo;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.FakeEnv;
+import org.apache.doris.catalog.HashDistributionInfo;
+import org.apache.doris.catalog.KeysType;
+import org.apache.doris.catalog.LocalReplica;
+import org.apache.doris.catalog.LocalTablet;
+import org.apache.doris.catalog.MaterializedIndex;
+import org.apache.doris.catalog.MaterializedIndex.IndexState;
+import org.apache.doris.catalog.MaterializedIndexMeta;
+import org.apache.doris.catalog.MetaIdGenerator.IdGeneratorBuffer;
+import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.catalog.Partition;
+import org.apache.doris.catalog.PartitionInfo;
+import org.apache.doris.catalog.PartitionItem;
+import org.apache.doris.catalog.PartitionKey;
+import org.apache.doris.catalog.RangePartitionInfo;
+import org.apache.doris.catalog.RangePartitionItem;
+import org.apache.doris.catalog.Replica.ReplicaState;
+import org.apache.doris.catalog.ReplicaAllocation;
+import org.apache.doris.catalog.ScalarType;
+import org.apache.doris.catalog.TableProperty;
+import org.apache.doris.catalog.TabletMeta;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.nereids.trees.plans.commands.info.AddPartitionOp;
+import org.apache.doris.system.Backend;
+import org.apache.doris.system.SystemInfoService;
+import org.apache.doris.system.SystemInfoService.HostInfo;
+import org.apache.doris.thrift.TStorageMedium;
+import org.apache.doris.thrift.TStorageType;
+import org.apache.doris.thrift.TTabletType;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Range;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class InternalCatalogTest {
+ private static final long TABLE_ID = 1000L;
+ private static final long INDEX_ID = 1000L;
+ private static final long PARTITION_ID = 1001L;
+ private static final long TABLET_ID = 1002L;
+ private static final long BACKEND_ID = 1003L;
+ private static final long REPLICA_ID = 1004L;
+ private static final long BACKEND_ID_2 = 1005L;
+ private static final long BACKEND_ID_3 = 1006L;
+ private static final String TABLE_NAME = "range_table";
+ private static final String PARTITION_NAME = "p0";
+ private static final String NEW_PARTITION_NAME = "p_commit_failed";
+
+ private Database db;
+ private FailingCommitInternalCatalog catalog;
+ private FakeEnv fakeEnv;
+
+ @Before
+ public void setUp() throws Exception {
+ fakeEnv = new FakeEnv();
Review Comment:
This test never closes the `FakeEnv` it creates. `FakeEnv` owns a
`Mockito.mockStatic(Env.class)` registration and only releases it from
`FakeEnv.close()`, and every other FE test that creates `new FakeEnv()` has an
`@After`/tearDown close. Leaving this static mock open can leak the mocked
`Env` into later tests in the same JVM, or make another `FakeEnv` setup fail
because the static mock is still registered. Please add an `@After` method that
closes `fakeEnv`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]