Skip to content

Commit

Permalink
Perform index checking in a caller thread (#82249) (#82252)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
idegtiarenko committed Jan 5, 2022
1 parent ce699ee commit 62e9e4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 3 additions & 0 deletions server/src/main/java/org/elasticsearch/index/store/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ public void renameTempFilesSafe(Map<String, String> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 62e9e4c

Please sign in to comment.