This is an automated email from the ASF dual-hosted git repository.
airborne pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 0d364bdb4bc [fix](inverted index) fix error when open empty index file
(#51393)
0d364bdb4bc is described below
commit 0d364bdb4bc2355e6e57cd70f36b284d4e19eec0
Author: airborne12 <[email protected]>
AuthorDate: Tue Jun 3 17:05:38 2025 +0800
[fix](inverted index) fix error when open empty index file (#51393)
Related PR: #50937
Problem Summary:
This PR fixes the error that occurs when attempting to open an empty
inverted index file by adding a proper empty file check and error
reporting.
Added a condition to verify if the file size is zero.
Sets an error message and returns false to prevent CLucene errors.
---
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 30c3e178732..8dbac071290 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 6443495b9f4..96c5ca74038 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
@@ -116,6 +116,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: [email protected]
For additional commands, e-mail: [email protected]