Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: prevent background merges on the realtime lucene index #13050

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.NoMergeScheduler;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
Expand Down Expand Up @@ -131,6 +132,15 @@ public LuceneTextIndexCreator(String column, File segmentIndexDir, boolean commi
indexWriterConfig.setCommitOnClose(commit);
indexWriterConfig.setUseCompoundFile(config.isLuceneUseCompoundFile());

// For the realtime segment, prevent background merging. The realtime segment will call .commit()
// on the IndexWriter when segment conversion occurs. By default, Lucene will sometimes choose to
// merge segments in the background, which is problematic because the lucene index directory's
// contents is copied to create the immutable segment. If a background merge occurs during this
// copy, a FileNotFoundException will be triggered and segment build will fail.
if (!_commitOnClose) {
indexWriterConfig.setMergeScheduler(NoMergeScheduler.INSTANCE);
}

if (_reuseMutableIndex) {
LOGGER.info("Reusing the realtime lucene index for segment {} and column {}", segmentIndexDir, column);
indexWriterConfig.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
Expand Down
Loading