From 49fa2096d69ae9817559ba1302adec26ec2eefba Mon Sep 17 00:00:00 2001 From: Ievgen Degtiarenko Date: Wed, 5 Jan 2022 12:19:41 +0100 Subject: [PATCH] Perform index checking in a caller thread (#82249) Since 8.11 lucene performs index checking concurrently using disposable fixed thread pool executor by default. Setting thread count to 1 to keep prior behavior (check is executed in single caller thread). --- .../src/main/java/org/elasticsearch/index/store/Store.java | 3 +++ .../store/input/BaseSearchableSnapshotIndexInput.java | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/store/Store.java b/server/src/main/java/org/elasticsearch/index/store/Store.java index 33e0b47f6db7e..fd246af0c8eb4 100644 --- a/server/src/main/java/org/elasticsearch/index/store/Store.java +++ b/server/src/main/java/org/elasticsearch/index/store/Store.java @@ -328,6 +328,9 @@ public void renameTempFilesSafe(Map tempFileMap) throws IOExcept public CheckIndex.Status checkIndex(PrintStream out) throws IOException { metadataLock.writeLock().lock(); try (CheckIndex checkIndex = new CheckIndex(directory)) { + // Since 8.11 lucene performs index checking concurrently using disposable fixed thread pool executor by default. + // Setting thread count to 1 to keep prior behaviour (check is executed in single caller thread). + checkIndex.setThreadCount(1); checkIndex.setInfoStream(out); return checkIndex.checkIndex(); } finally { diff --git a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/store/input/BaseSearchableSnapshotIndexInput.java b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/store/input/BaseSearchableSnapshotIndexInput.java index 1bf7001cb846b..e194cfe70f89d 100644 --- a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/store/input/BaseSearchableSnapshotIndexInput.java +++ b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/store/input/BaseSearchableSnapshotIndexInput.java @@ -300,12 +300,8 @@ protected final boolean assertCurrentThreadMayAccessBlobStore() { // Cache prewarming also runs on a dedicated thread pool. || threadName.contains('[' + SearchableSnapshots.CACHE_PREWARMING_THREAD_POOL_NAME + ']') - // Unit tests access the blob store on the main test thread, or via an asynchronous - // checkindex call; - // simplest just to permit this rather than have them override this - // method somehow. + // Unit tests access the blob store on the main test thread; simplest just to permit this rather than have them override this || threadName.startsWith("TEST-") - || threadName.startsWith("async-check-index") || threadName.startsWith("LuceneTestCase") : "current thread [" + Thread.currentThread() + "] may not read " + fileInfo; return true; }