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

Core: Don't forcefully release IW lock (this can cause corruption) #8892

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1432,11 +1432,6 @@ private static boolean isMergedSegment(AtomicReader reader) {

private IndexWriter createWriter() throws IOException {
try {
// release locks when started
if (IndexWriter.isLocked(store.directory())) {
logger.warn("shard is locked, releasing lock");
IndexWriter.unlock(store.directory());
}
boolean create = !Lucene.indexExists(store.directory());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huge +1

IndexWriterConfig config = new IndexWriterConfig(Lucene.VERSION, analysisService.defaultIndexAnalyzer());
config.setOpenMode(create ? IndexWriterConfig.OpenMode.CREATE : IndexWriterConfig.OpenMode.APPEND);
Expand Down
Expand Up @@ -388,6 +388,7 @@ public void run() {

@Test
public void testSegmentsWithMergeFlag() throws Exception {

ConcurrentMergeSchedulerProvider mergeSchedulerProvider = new ConcurrentMergeSchedulerProvider(shardId, EMPTY_SETTINGS, threadPool, new IndexSettingsService(shardId.index(), EMPTY_SETTINGS));
final AtomicReference<CountDownLatch> waitTillMerge = new AtomicReference<>();
final AtomicReference<CountDownLatch> waitForMerge = new AtomicReference<>();
Expand All @@ -411,6 +412,7 @@ public void afterMerge(OnGoingMerge merge) {
}
});

final Store store = createStore();
final Engine engine = createEngine(engineSettingsService, store, createTranslog(), mergeSchedulerProvider);
engine.start();
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), Lucene.STANDARD_ANALYZER, B_1, false);
Expand Down Expand Up @@ -481,6 +483,7 @@ public boolean apply(Object o) {
}

engine.close();
store.close();
}

@Test
Expand Down Expand Up @@ -1364,6 +1367,7 @@ public void testEnableGcDeletes() throws Exception {
.put(InternalEngineHolder.INDEX_GC_DELETES, "0ms")
.build();

Store store = createStore();
Engine engine = new InternalEngineHolder(shardId, settings, threadPool,
engineSettingsService,
new ShardIndexingService(shardId, settings,
Expand Down Expand Up @@ -1426,6 +1430,7 @@ null, store, createSnapshotDeletionPolicy(), createTranslog(), createMergePolicy
getResult = engine.get(new Engine.Get(true, newUid("2")));
assertThat(getResult.exists(), equalTo(false));
engine.close();
store.close();
}

protected Term newUid(String id) {
Expand Down