Revert "[fix](tablet invert index) fix tablet invert index leaky caused by auto partition (#33714)"

This reverts commit 89441b0cb0e27e332e7a806838c0fdac47f1de26.
This commit is contained in:
yiguolei
2024-04-21 20:26:06 +08:00
parent c6fad11154
commit 18d191b293
2 changed files with 8 additions and 66 deletions

View File

@ -1416,9 +1416,7 @@ public class InternalCatalog implements CatalogIf<Database> {
if (olapTable.checkPartitionNameExist(partitionName)) {
if (singlePartitionDesc.isSetIfNotExists()) {
LOG.info("add partition[{}] which already exists", partitionName);
if (!DebugPointUtil.isEnable("InternalCatalog.addPartition.noCheckExists")) {
return;
}
return;
} else {
ErrorReport.reportDdlException(ErrorCode.ERR_SAME_NAME_PARTITION, partitionName);
}
@ -1575,7 +1573,6 @@ public class InternalCatalog implements CatalogIf<Database> {
if (!Strings.isNullOrEmpty(dataProperty.getStoragePolicy())) {
storagePolicy = dataProperty.getStoragePolicy();
}
boolean ignoreException = false;
try {
long partitionId = idGeneratorBuffer.getNextId();
Partition partition = createPartitionWithIndices(db.getId(), olapTable,
@ -1596,10 +1593,11 @@ public class InternalCatalog implements CatalogIf<Database> {
// check partition name
if (olapTable.checkPartitionNameExist(partitionName)) {
if (singlePartitionDesc.isSetIfNotExists()) {
ignoreException = true;
LOG.info("add partition[{}] which already exists", partitionName);
return;
} else {
ErrorReport.reportDdlException(ErrorCode.ERR_SAME_NAME_PARTITION, partitionName);
}
LOG.info("add partition[{}] which already exists", partitionName);
ErrorReport.reportDdlException(ErrorCode.ERR_SAME_NAME_PARTITION, partitionName);
}
// check if meta changed
@ -1644,6 +1642,8 @@ public class InternalCatalog implements CatalogIf<Database> {
}
}
if (metaChanged) {
throw new DdlException("Table[" + tableName + "]'s meta has been changed. try again.");
}
@ -1688,9 +1688,7 @@ public class InternalCatalog implements CatalogIf<Database> {
for (Long tabletId : tabletIdSet) {
Env.getCurrentInvertedIndex().deleteTablet(tabletId);
}
if (!ignoreException) {
throw e;
}
throw e;
}
}

View File

@ -1,56 +0,0 @@
// 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.alter;
import org.apache.doris.catalog.Env;
import org.apache.doris.common.Config;
import org.apache.doris.common.util.DebugPointUtil;
import org.apache.doris.common.util.DebugPointUtil.DebugPoint;
import org.apache.doris.utframe.TestWithFeService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.List;
public class AddExistsPartitionTest extends TestWithFeService {
@Override
protected void beforeCreatingConnectContext() throws Exception {
Config.enable_debug_points = true;
}
@Test
public void testAddExistsPartition() throws Exception {
DebugPointUtil.addDebugPoint("InternalCatalog.addPartition.noCheckExists", new DebugPoint());
createDatabase("test");
createTable("CREATE TABLE test.tbl (k INT) DISTRIBUTED BY HASH(k) "
+ " BUCKETS 5 PROPERTIES ( \"replication_num\" = \"" + backendNum() + "\" )");
List<Long> backendIds = Env.getCurrentSystemInfo().getAllBackendIds();
for (long backendId : backendIds) {
Assertions.assertEquals(5, Env.getCurrentInvertedIndex().getTabletIdsByBackendId(backendId).size());
}
String addPartitionSql = "ALTER TABLE test.tbl ADD PARTITION IF NOT EXISTS tbl"
+ " DISTRIBUTED BY HASH(k) BUCKETS 5";
Assertions.assertNotNull(getSqlStmtExecutor(addPartitionSql));
for (long backendId : backendIds) {
Assertions.assertEquals(5, Env.getCurrentInvertedIndex().getTabletIdsByBackendId(backendId).size());
}
}
}