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

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


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new a8d421e9c34 [Fix](inverted index) fix build index error status when 
batch_next (#33532) (#33818)
a8d421e9c34 is described below

commit a8d421e9c342687f9eed81425d7ce7c5d4c700e3
Author: airborne12 <airborn...@gmail.com>
AuthorDate: Thu Apr 18 14:16:08 2024 +0800

    [Fix](inverted index) fix build index error status when batch_next (#33532) 
(#33818)
---
 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 ddfd027b34f..be41f8b3706 100644
--- a/be/src/olap/task/index_builder.cpp
+++ b/be/src/olap/task/index_builder.cpp
@@ -26,6 +26,7 @@
 #include "olap/tablet_schema.h"
 #include "runtime/memory/mem_tracker.h"
 #include "runtime/thread_context.h"
+#include "util/debug_points.h"
 #include "util/trace.h"
 
 namespace doris {
@@ -222,6 +223,10 @@ Status 
IndexBuilder::handle_single_rowset(RowsetMetaSharedPtr output_rowset_meta
                     output_rowset_schema->create_block(return_columns));
             while (true) {
                 auto st = iter->next_batch(block.get());
+                DBUG_EXECUTE_IF("IndexBuilder::handle_single_rowset", {
+                    st = Status::Error<ErrorCode::SCHEMA_CHANGE_INFO_INVALID>(
+                            "next_batch fault injection");
+                });
                 if (!st.ok()) {
                     if (st.is<ErrorCode::END_OF_FILE>()) {
                         break;
@@ -229,6 +234,7 @@ Status 
IndexBuilder::handle_single_rowset(RowsetMetaSharedPtr output_rowset_meta
                     LOG(WARNING)
                             << "failed to read next block when schema change 
for inverted index."
                             << ", err=" << st.to_string();
+                    return st;
                 }
 
                 // 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 3c8e7bc57f4..21f53f9759c 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
@@ -183,7 +183,7 @@ suite("test_build_index_fault", "inverted_index"){
     // 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}; """
 
@@ -200,7 +200,7 @@ suite("test_build_index_fault", "inverted_index"){
     // 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}; """
 
@@ -210,7 +210,7 @@ suite("test_build_index_fault", "inverted_index"){
     
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}; """
 
@@ -218,7 +218,23 @@ suite("test_build_index_fault", "inverted_index"){
     
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-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to