From f134b41cdb8bfa93df1917fc1e83548852f73253 Mon Sep 17 00:00:00 2001 From: aoiasd <45024769+aoiasd@users.noreply.github.com> Date: Wed, 7 Jan 2026 15:21:03 +0800 Subject: [PATCH] fix: [2.5] inverted index null offset file not compacted (#46775) (#46868) relate: https://github.com/milvus-io/milvus/issues/46774 pr: https://github.com/milvus-io/milvus/pull/46775 Signed-off-by: aoiasd --- internal/core/src/index/InvertedIndexTantivy.cpp | 10 ++++++++++ internal/core/src/index/JsonInvertedIndex.cpp | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/internal/core/src/index/InvertedIndexTantivy.cpp b/internal/core/src/index/InvertedIndexTantivy.cpp index 788cece753..2eb9a268b7 100644 --- a/internal/core/src/index/InvertedIndexTantivy.cpp +++ b/internal/core/src/index/InvertedIndexTantivy.cpp @@ -215,7 +215,13 @@ InvertedIndexTantivy::LoadIndexMetas( if (file_name.find(INDEX_NULL_OFFSET_FILE_NAME) != std::string::npos) { null_offset_files.push_back(file); } + + // add slice meta file for null offset file compact + if (file_name == INDEX_FILE_SLICE_META) { + null_offset_files.push_back(file); + } } + if (null_offset_files.size() > 0) { // null offset file is sliced auto index_datas = @@ -243,6 +249,10 @@ InvertedIndexTantivy::RetainTantivyIndexFiles( auto file_name = boost::filesystem::path(file).filename().string(); return file_name == "index_type" || + // Slice meta is only used to compact null_offset files and non_exist_offset files. + // It can be removed after compaction is complete. + // Other index files are compacted by slice index instead of meta. + file_name == INDEX_FILE_SLICE_META || file_name.find(INDEX_NULL_OFFSET_FILE_NAME) != std::string::npos; }), diff --git a/internal/core/src/index/JsonInvertedIndex.cpp b/internal/core/src/index/JsonInvertedIndex.cpp index 8307fa31d1..cddca6a641 100644 --- a/internal/core/src/index/JsonInvertedIndex.cpp +++ b/internal/core/src/index/JsonInvertedIndex.cpp @@ -234,6 +234,10 @@ JsonInvertedIndex::LoadIndexMetas( std::string::npos) { non_exist_offset_files.push_back(file); } + // add slice meta file for null offset file compact + if (file_name == INDEX_FILE_SLICE_META) { + non_exist_offset_files.push_back(file); + } } if (non_exist_offset_files.size() > 0) { // null offset file is sliced