This is an automated email from the ASF dual-hosted git repository.
kxiao 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 cc85f7b94c2 [fix](build index)Remove index_meta in tablet schema when
the index is dropped. (#37646) (#37897)
cc85f7b94c2 is described below
commit cc85f7b94c2775814db058e6742522bfa8711e0d
Author: qiye <[email protected]>
AuthorDate: Tue Jul 16 20:32:30 2024 +0800
[fix](build index)Remove index_meta in tablet schema when the index is
dropped. (#37646) (#37897)
---
be/src/olap/task/index_builder.cpp | 22 +++++
...index_builder_drop_index_fault_injection.groovy | 107 +++++++++++++++++++++
2 files changed, 129 insertions(+)
diff --git a/be/src/olap/task/index_builder.cpp
b/be/src/olap/task/index_builder.cpp
index fd7d6b5edf2..b0b7eb46d19 100644
--- a/be/src/olap/task/index_builder.cpp
+++ b/be/src/olap/task/index_builder.cpp
@@ -18,6 +18,7 @@
#include "olap/task/index_builder.h"
#include "common/status.h"
+#include "gutil/integral_types.h"
#include "olap/rowset/beta_rowset.h"
#include "olap/rowset/rowset_writer_context.h"
#include "olap/rowset/segment_v2/inverted_index_file_reader.h"
@@ -112,7 +113,28 @@ Status IndexBuilder::update_inverted_index_info() {
}
}
_dropped_inverted_indexes.push_back(*index_meta);
+ // ATTN: DO NOT REMOVE INDEX AFTER OUTPUT_ROWSET_WRITER
CREATED.
+ // remove dropped index_meta from output rowset tablet schema
+ output_rs_tablet_schema->remove_index(index_meta->index_id());
}
+
DBUG_EXECUTE_IF("index_builder.update_inverted_index_info.drop_index", {
+ auto indexes_count =
DebugPoints::instance()->get_debug_param_or_default<int32_t>(
+ "index_builder.update_inverted_index_info.drop_index",
"indexes_count", 0);
+ if (indexes_count < 0) {
+ return Status::Error<ErrorCode::INTERNAL_ERROR>(
+ "indexes count cannot be negative");
+ }
+ int32_t indexes_size = 0;
+ for (auto index : output_rs_tablet_schema->indexes()) {
+ if (index.index_type() == IndexType::INVERTED) {
+ indexes_size++;
+ }
+ }
+ if (indexes_count != indexes_size) {
+ return Status::Error<ErrorCode::INTERNAL_ERROR>(
+ "indexes count not equal to expected");
+ }
+ })
} else {
// base on input rowset's tablet_schema to build
// output rowset's tablet_schema which only add
diff --git
a/regression-test/suites/fault_injection_p0/test_index_builder_drop_index_fault_injection.groovy
b/regression-test/suites/fault_injection_p0/test_index_builder_drop_index_fault_injection.groovy
new file mode 100644
index 00000000000..e4a620aa9d1
--- /dev/null
+++
b/regression-test/suites/fault_injection_p0/test_index_builder_drop_index_fault_injection.groovy
@@ -0,0 +1,107 @@
+// 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.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+suite("test_index_builder_drop_index_fault_injection", "nonConcurrent") {
+ def runTest = { indexTbName ->
+ sql """ insert into ${indexTbName} values(1, "json love anny", "json",
"anny",1); """
+ sql "sync"
+
+ def show_result = sql_return_maparray "show index from ${indexTbName}"
+ logger.info("show index from " + indexTbName + " result: " +
show_result)
+ assertEquals(show_result.size(), 4)
+ assertEquals(show_result[0].Key_name, "index_int")
+ assertEquals(show_result[1].Key_name, "index_str_k2")
+ assertEquals(show_result[2].Key_name, "index_str_k4")
+ assertEquals(show_result[3].Key_name, "index_k5")
+
+ try {
+
GetDebugPoint().enableDebugPointForAllBEs("segment_iterator._read_columns_by_index",
[indexes_count: 3])
+ sql "DROP INDEX index_int ON ${indexTbName}"
+ show_result = sql_return_maparray "show index from ${indexTbName}"
+ logger.info("show index from " + indexTbName + " result: " +
show_result)
+ assertEquals(show_result.size(), 3)
+ assertEquals(show_result[0].Key_name, "index_str_k2")
+ assertEquals(show_result[1].Key_name, "index_str_k4")
+ assertEquals(show_result[2].Key_name, "index_k5")
+ } finally {
+
GetDebugPoint().disableDebugPointForAllBEs("index_builder.update_inverted_index_info.drop_index")
+ }
+
+ try {
+
GetDebugPoint().enableDebugPointForAllBEs("segment_iterator._read_columns_by_index",
[indexes_count: 2])
+ sql "DROP INDEX index_str_k2 ON ${indexTbName}"
+ show_result = sql_return_maparray "show index from ${indexTbName}"
+ logger.info("show index from " + indexTbName + " result: " +
show_result)
+ assertEquals(show_result.size(), 2)
+ assertEquals(show_result[0].Key_name, "index_str_k4")
+ assertEquals(show_result[1].Key_name, "index_k5")
+ } finally {
+
GetDebugPoint().disableDebugPointForAllBEs("index_builder.update_inverted_index_info.drop_index")
+ }
+
+ try {
+
GetDebugPoint().enableDebugPointForAllBEs("segment_iterator._read_columns_by_index",
[indexes_count: 1])
+ sql "DROP INDEX index_str_k4 ON ${indexTbName}"
+ show_result = sql_return_maparray "show index from ${indexTbName}"
+ logger.info("show index from " + indexTbName + " result: " +
show_result)
+ assertEquals(show_result.size(), 1)
+ assertEquals(show_result[0].Key_name, "index_k5")
+ } finally {
+
GetDebugPoint().disableDebugPointForAllBEs("index_builder.update_inverted_index_info.drop_index")
+ }
+
+ try {
+
GetDebugPoint().enableDebugPointForAllBEs("segment_iterator._read_columns_by_index",
[indexes_count: 0])
+ sql "DROP INDEX index_k5 ON ${indexTbName}"
+ show_result = sql_return_maparray "show index from ${indexTbName}"
+ logger.info("show index from " + indexTbName + " result: " +
show_result)
+ assertEquals(show_result.size(), 0)
+ } finally {
+
GetDebugPoint().disableDebugPointForAllBEs("index_builder.update_inverted_index_info.drop_index")
+ }
+ }
+
+ def createTestTable = { version ->
+ def indexTbName =
"test_index_builder_drop_index_fault_injection_${version}"
+
+ sql "DROP TABLE IF EXISTS ${indexTbName}"
+ sql """
+ CREATE TABLE ${indexTbName}
+ (
+ k1 int ,
+ k2 string,
+ k3 char(50),
+ k4 varchar(200),
+ k5 int,
+ index index_int (k1) using inverted,
+ index index_str_k2 (k2) using inverted
properties("parser"="english","ignore_above"="257"),
+ index index_str_k4 (k4) using inverted,
+ index index_k5 (k5) using inverted
+ )
+ DISTRIBUTED BY RANDOM BUCKETS 10
+ PROPERTIES("replication_num" =
"1","inverted_index_storage_format"="${version}");
+ """
+
+ runTest(indexTbName)
+ }
+
+ createTestTable("v1")
+ createTestTable("v2")
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]