Skip to content

Commit 05ddcdb

Browse files
tlrxfcofdez
authored andcommitted
Use read/write engine lock to guard operations against resets (elastic#124635)
Today shard's engine mutation are guarded by an engineMutex object monitor. But we would like to be able to execute one or more operations on an engine instance, without this instance being resetted during the execution of the operation. In order to do that, this change replaces the engineMutex by a reentrant read/write lock and introduces two new methods IndexShard#withEngine() and IndexShard#withEngineOrNull() that can be used to execute an operation while avoiding the current engine instance to be reset. It does not prevent it to be closed during execution though. Relates ES-10826 Co-authored-by: Francisco Fernández Castaño <[email protected]>
1 parent d89c9a6 commit 05ddcdb

File tree

3 files changed

+319
-72
lines changed

3 files changed

+319
-72
lines changed

server/src/main/java/org/elasticsearch/index/engine/Engine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,7 @@ public record FlushResult(boolean flushPerformed, long generation) {
23712371
}
23722372

23732373
/**
2374-
* Ensures the engine is in a state that it can be closed by a call to {@link IndexShard#resetEngine()}.
2374+
* Ensures the engine is in a state that it can be closed by a call to {@link IndexShard#resetEngine(Consumer<Engine>)}.
23752375
*
23762376
* In general, resetting the engine should be done with care, to consider any
23772377
* in-progress operations and listeners (e.g., primary term and generation listeners).

0 commit comments

Comments
 (0)