Skip to content

Perform index checking in a caller thread #82249

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

Merged
merged 1 commit into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
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
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