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

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

commit 2c8d4cd907f37dd61fe1def5fd509dd8c1b1869d
Author: zzzxl <[email protected]>
AuthorDate: Sat Nov 4 14:52:35 2023 +0800

    [fix](invert index) Fix the timing error when opening the searcher (#26401)
---
 be/src/olap/rowset/segment_v2/inverted_index_reader.cpp | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp 
b/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp
index 325907fa14d..df0baa40ade 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp
+++ b/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp
@@ -281,10 +281,12 @@ Status FullTextIndexReader::query(OlapReaderStatistics* 
stats, RuntimeState* run
                     "inverted index path: {} not exist.", 
index_file_path.string());
         }
 
-        InvertedIndexCacheHandle inverted_index_cache_handle;
-        InvertedIndexSearcherCache::instance()->get_index_searcher(
-                _fs, index_dir.c_str(), index_file_name, 
&inverted_index_cache_handle, stats);
-        auto index_searcher = inverted_index_cache_handle.get_index_searcher();
+        auto get_index_search = [this, &index_dir, &index_file_name, &stats]() 
{
+            InvertedIndexCacheHandle inverted_index_cache_handle;
+            
static_cast<void>(InvertedIndexSearcherCache::instance()->get_index_searcher(
+                    _fs, index_dir.c_str(), index_file_name, 
&inverted_index_cache_handle, stats));
+            return inverted_index_cache_handle.get_index_searcher();
+        };
 
         std::unique_ptr<lucene::search::Query> query;
         std::wstring field_ws = std::wstring(column_name.begin(), 
column_name.end());
@@ -315,6 +317,8 @@ Status FullTextIndexReader::query(OlapReaderStatistics* 
stats, RuntimeState* run
             } else {
                 stats->inverted_index_query_cache_miss++;
 
+                auto index_searcher = get_index_search();
+
                 term_match_bitmap = std::make_shared<roaring::Roaring>();
 
                 Status res = Status::OK();
@@ -363,6 +367,8 @@ Status FullTextIndexReader::query(OlapReaderStatistics* 
stats, RuntimeState* run
                 } else {
                     stats->inverted_index_query_cache_miss++;
 
+                    auto index_searcher = get_index_search();
+
                     term_match_bitmap = std::make_shared<roaring::Roaring>();
                     // unique_ptr with custom deleter
                     std::unique_ptr<lucene::index::Term, void 
(*)(lucene::index::Term*)> term {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to