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

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


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new f23dae0f2fa branch-3.0: [fix](inverted index) fix error when open 
empty index file #51393 (#51438)
f23dae0f2fa is described below

commit f23dae0f2fa08a2afcf533f12ce7f55d6734a1b2
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Jun 11 10:59:27 2025 +0800

    branch-3.0: [fix](inverted index) fix error when open empty index file 
#51393 (#51438)
    
    Cherry-picked from #51393
    
    Co-authored-by: airborne12 <jiang...@selectdb.com>
---
 be/src/olap/rowset/segment_v2/inverted_index_file_reader.cpp   |  3 +++
 be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp  |  4 ++++
 .../inverted_index_p0/test_variant_empty_index_file.groovy     | 10 ++++++++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/be/src/olap/rowset/segment_v2/inverted_index_file_reader.cpp 
b/be/src/olap/rowset/segment_v2/inverted_index_file_reader.cpp
index 3a32f7ccdec..1b9440ae14b 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_file_reader.cpp
+++ b/be/src/olap/rowset/segment_v2/inverted_index_file_reader.cpp
@@ -67,6 +67,9 @@ Status InvertedIndexFileReader::_init_from(int32_t 
read_buffer_size, const io::I
             if (err.number() == CL_ERR_FileNotFound) {
                 return Status::Error<ErrorCode::INVERTED_INDEX_FILE_NOT_FOUND>(
                         "inverted index file {} is not found.", 
index_file_full_path);
+            } else if (err.number() == CL_ERR_EmptyIndexSegment) {
+                return Status::Error<ErrorCode::INVERTED_INDEX_BYPASS>(
+                        "inverted index file {} is empty.", 
index_file_full_path);
             }
             return Status::Error<ErrorCode::INVERTED_INDEX_CLUCENE_ERROR>(
                     "CLuceneError occur when open idx file {}, error msg: {}", 
index_file_full_path,
diff --git a/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp 
b/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp
index b1d1af7ee3c..759cc0b430b 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp
+++ b/be/src/olap/rowset/segment_v2/inverted_index_fs_directory.cpp
@@ -149,6 +149,10 @@ bool DorisFSDirectory::FSIndexInput::open(const 
io::FileSystemSPtr& fs, const ch
         if (h->_reader->size() == 0) {
             // may be an empty file
             LOG(INFO) << "Opened inverted index file is empty, file is " << 
path;
+            // need to return false to avoid the error of CLucene
+            error.set(CL_ERR_EmptyIndexSegment,
+                      fmt::format("File is empty, file is {}", path).data());
+            return false;
         }
         //Store the file length
         h->_length = h->_reader->size();
diff --git 
a/regression-test/suites/inverted_index_p0/test_variant_empty_index_file.groovy 
b/regression-test/suites/inverted_index_p0/test_variant_empty_index_file.groovy
index 8ad4f0c1924..dc98eed4802 100644
--- 
a/regression-test/suites/inverted_index_p0/test_variant_empty_index_file.groovy
+++ 
b/regression-test/suites/inverted_index_p0/test_variant_empty_index_file.groovy
@@ -50,8 +50,14 @@ suite("test_variant_empty_index_file", "p0") {
     if (!isCloudMode()) {
         def (code, out, err) = http_client("GET", 
String.format("http://%s:%s/api/show_nested_index_file?tablet_id=%s";, ip, port, 
tablet_id))
         logger.info("Run show_nested_index_file_on_tablet: code=" + code + ", 
out=" + out + ", err=" + err)
-        assertEquals("E-6002", parseJson(out.trim()).status)
+        assertEquals("E-6004", parseJson(out.trim()).status)
+        assertTrue(out.contains(" is empty"))
     }
 
-    qt_sql """ select * from ${tableName} where v match 'abcd'"""
+    try {
+        sql """ select /*+ SET_VAR(enable_match_without_inverted_index = 0) */ 
 * from ${tableName} where v match 'abcd';  """
+    } catch (Exception e) {
+        log.info(e.getMessage());
+        assertTrue(e.getMessage().contains("match_any not support 
execute_match"))
+    }
 }
\ No newline at end of file


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

Reply via email to