You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2024/04/12 15:12:01 UTC

(doris) 02/24: [Fix](inverted index) fix build index error status when batch_next (#33532)

This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 97f204cb7b0d8ec6ecaa8606906efb1203f3f0bb
Author: airborne12 <ai...@gmail.com>
AuthorDate: Thu Apr 11 21:26:00 2024 +0800

    [Fix](inverted index) fix build index error status when batch_next (#33532)
---
 be/src/olap/task/index_builder.cpp                 |  6 ++++++
 .../fault_injection_p0/test_build_index_fault.out  |  6 ++++++
 .../test_build_index_fault.groovy                  | 24 ++++++++++++++++++----
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/be/src/olap/task/index_builder.cpp b/be/src/olap/task/index_builder.cpp
index 062a6880578..0e6abc2c1b1 100644
--- a/be/src/olap/task/index_builder.cpp
+++ b/be/src/olap/task/index_builder.cpp
@@ -27,6 +27,7 @@
 #include "olap/segment_loader.h"
 #include "olap/storage_engine.h"
 #include "olap/tablet_schema.h"
+#include "util/debug_points.h"
 #include "util/trace.h"
 
 namespace doris {
@@ -395,6 +396,10 @@ Status IndexBuilder::handle_single_rowset(RowsetMetaSharedPtr output_rowset_meta
                     output_rowset_schema->create_block(return_columns));
             while (true) {
                 auto status = iter->next_batch(block.get());
+                DBUG_EXECUTE_IF("IndexBuilder::handle_single_rowset", {
+                    status = Status::Error<ErrorCode::SCHEMA_CHANGE_INFO_INVALID>(
+                            "next_batch fault injection");
+                });
                 if (!status.ok()) {
                     if (status.is<ErrorCode::END_OF_FILE>()) {
                         break;
@@ -402,6 +407,7 @@ Status IndexBuilder::handle_single_rowset(RowsetMetaSharedPtr output_rowset_meta
                     LOG(WARNING)
                             << "failed to read next block when schema change for inverted index."
                             << ", err=" << status.to_string();
+                    return status;
                 }
 
                 // write inverted index data
diff --git a/regression-test/data/fault_injection_p0/test_build_index_fault.out b/regression-test/data/fault_injection_p0/test_build_index_fault.out
index 543ca7ae5ff..3d5d60cfcaa 100644
--- a/regression-test/data/fault_injection_p0/test_build_index_fault.out
+++ b/regression-test/data/fault_injection_p0/test_build_index_fault.out
@@ -17,3 +17,9 @@
 -- !count6 --
 1000000
 
+-- !count7 --
+1000000
+
+-- !count8 --
+1000000
+
diff --git a/regression-test/suites/fault_injection_p0/test_build_index_fault.groovy b/regression-test/suites/fault_injection_p0/test_build_index_fault.groovy
index 988db48c6a7..84e0bae24ad 100644
--- a/regression-test/suites/fault_injection_p0/test_build_index_fault.groovy
+++ b/regression-test/suites/fault_injection_p0/test_build_index_fault.groovy
@@ -192,7 +192,7 @@ suite("test_build_index_fault", "inverted_index, nonConcurrent,p2"){
     // BUILD INDEX and expect state is FINISHED
     sql """ BUILD INDEX idx_comment ON ${tableName}; """
     state = wait_for_last_build_index_on_table_finish(tableName, timeout)
-    assertEquals(state, "FINISHED")
+    assertEquals("FINISHED", state)
     // check data
     qt_count3 """ SELECT COUNT() from ${tableName}; """
 
@@ -209,7 +209,7 @@ suite("test_build_index_fault", "inverted_index, nonConcurrent,p2"){
     // BUILD INDEX again and expect state is FINISHED
     sql """ BUILD INDEX idx_comment ON ${tableName}; """
     state = wait_for_last_build_index_on_table_finish(tableName, timeout)
-    assertEquals(state, "FINISHED")
+    assertEquals("FINISHED", state)
     // check data
     qt_count4 """ SELECT COUNT() from ${tableName}; """
 
@@ -219,7 +219,7 @@ suite("test_build_index_fault", "inverted_index, nonConcurrent,p2"){
     GetDebugPoint().enableDebugPointForAllBEs("fault_inject::BetaRowset::link_files_to::_link_inverted_index_file")
     sql """ BUILD INDEX idx_title ON ${tableName}; """
     state = wait_for_last_build_index_on_table_finish(tableName, timeout)
-    assertEquals(state, "wait_timeout")
+    assertEquals("wait_timeout", state)
     // check data
     qt_count5 """ SELECT COUNT() from ${tableName}; """
 
@@ -227,7 +227,23 @@ suite("test_build_index_fault", "inverted_index, nonConcurrent,p2"){
     GetDebugPoint().disableDebugPointForAllBEs("fault_inject::BetaRowset::link_files_to::_link_inverted_index_file")
     // timeout * 10 for possible fe schedule delay
     state = wait_for_last_build_index_on_table_finish(tableName, timeout * 10)
-    assertEquals(state, "FINISHED")
+    assertEquals("FINISHED", state)
     // check data
     qt_count6 """ SELECT COUNT() from ${tableName}; """
+
+    // BUILD INDEX with error injection
+    sql """ ALTER TABLE ${tableName} ADD INDEX idx_url (`url`) USING INVERTED """
+    GetDebugPoint().enableDebugPointForAllBEs("IndexBuilder::handle_single_rowset")
+    sql """ BUILD INDEX idx_url ON ${tableName}; """
+    state = wait_for_last_build_index_on_table_finish(tableName, timeout)
+    assertEquals("wait_timeout", state)
+    // check data
+    qt_count7 """ SELECT COUNT() from ${tableName}; """
+
+    GetDebugPoint().disableDebugPointForAllBEs("IndexBuilder::handle_single_rowset")
+    // timeout * 10 for possible fe schedule delay
+    state = wait_for_last_build_index_on_table_finish(tableName, timeout * 10)
+    assertEquals("FINISHED", state)
+    // check data
+    qt_count8 """ SELECT COUNT() from ${tableName}; """
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org