-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Add a frozen engine implementation #34357
Conversation
This change adds a `frozen` engine that allows lazily open a directory reader on a read-only shard. The engine wraps general purpose searchers in a LazyDirectoryReader that also allows to release and reset the underlying index readers after any and before secondary search phases. Relates to elastic#34352 F
Pinging @elastic/es-distributed |
This change adds a high level freeze API that allows to open an index frozen and vice versa. Indices must be closed in order to become frozen and an open but frozen index must be closed to be defrosted. This change also adds a `index.frozen` setting to mark frozen indices and integrates the frozen engine with the `SearchOperationListener` that resets and releases the directory reader after and before search phases. Relates to elastic#34352 Depends on elastic#34357
`Engine.Searcher` is non-final today which makes it error prone in the case of wrapping the underlying reader or lucene `IndexSearcher` like we do in `IndexSearcherWrapper`. Yet, there is no subclass of it yet that would be dramtic to just drop on the floor. With the start of development of frozen indices this changed since in elastic#34357 functionality was added to a subclass which would be dropped if a `IndexSearcherWrapper` is installed on an index. This change locks down the `Engine.Searcher` to prevent such a functionality trap.
`Engine.Searcher` is non-final today which makes it error prone in the case of wrapping the underlying reader or lucene `IndexSearcher` like we do in `IndexSearcherWrapper`. Yet, there is no subclass of it yet that would be dramatic to just drop on the floor. With the start of development of frozen indices this changed since in #34357 functionality was added to a subclass which would be dropped if a `IndexSearcherWrapper` is installed on an index. This change locks down the `Engine.Searcher` to prevent such a functionality trap.
`Engine.Searcher` is non-final today which makes it error prone in the case of wrapping the underlying reader or lucene `IndexSearcher` like we do in `IndexSearcherWrapper`. Yet, there is no subclass of it yet that would be dramatic to just drop on the floor. With the start of development of frozen indices this changed since in #34357 functionality was added to a subclass which would be dropped if a `IndexSearcherWrapper` is installed on an index. This change locks down the `Engine.Searcher` to prevent such a functionality trap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments. My only real question is where reset() and release() are going to be called from?
|
||
@Override | ||
protected DirectoryReader open(Directory directory) throws IOException { | ||
// we fake an empty directly reader for the ReadOnlyEngine. this reader is only used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/directly/directory/
x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/FrozenEngine.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/FrozenEngine.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/FrozenEngine.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/test/java/org/elasticsearch/index/engine/FrozenEngineTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/FrozenEngine.java
Show resolved
Hide resolved
good one, This will be exposed in a followup. I do have a branch for this already but I didn't want to make this change too big. The relevant code is here |
TIL about SearchOperationListener. Nice. |
libs/core/src/main/java/org/elasticsearch/core/internal/io/IOUtils.java
Outdated
Show resolved
Hide resolved
`Engine.Searcher` is non-final today which makes it error prone in the case of wrapping the underlying reader or lucene `IndexSearcher` like we do in `IndexSearcherWrapper`. Yet, there is no subclass of it yet that would be dramatic to just drop on the floor. With the start of development of frozen indices this changed since in #34357 functionality was added to a subclass which would be dropped if a `IndexSearcherWrapper` is installed on an index. This change locks down the `Engine.Searcher` to prevent such a functionality trap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@s1monw as discussed - these were my comments and questions.
x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/FrozenEngine.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/FrozenEngine.java
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/FrozenEngine.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/FrozenEngine.java
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/FrozenEngine.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/FrozenEngine.java
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/FrozenEngine.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/test/java/org/elasticsearch/index/engine/FrozenEngineTests.java
Show resolved
Hide resolved
This change adds a high level freeze API that allows to mark an index as frozen and vice versa. Indices must be closed in order to become frozen and an open but frozen index must be closed to be defrosted. This change also adds a index.frozen setting to mark frozen indices and integrates the frozen engine with the SearchOperationListener that resets and releases the directory reader after and before search phases. Relates to #34352 Depends on #34357
This change adds a special caching reader that caches all relevant values for a range query to rewrite correctly in a can_match phase without actually opening the underlying directory reader. This allows frozen indices to be filtered with can_match and in-turn searched with wildcards in a efficient way since it allows us to exclude shards that won't match based on their date-ranges without opening their directory readers. Relates to elastic#34352 Depends on elastic#34357
This change adds a `frozen` engine that allows lazily open a directory reader on a read-only shard. The engine wraps general purpose searchers in a LazyDirectoryReader that also allows to release and reset the underlying index readers after any and before secondary search phases. Relates to elastic#34352
This change adds a special caching reader that caches all relevant values for a range query to rewrite correctly in a can_match phase without actually opening the underlying directory reader. This allows frozen indices to be filtered with can_match and in-turn searched with wildcards in a efficient way since it allows us to exclude shards that won't match based on their date-ranges without opening their directory readers. Relates to #34352 Depends on #34357
This change adds a special caching reader that caches all relevant values for a range query to rewrite correctly in a can_match phase without actually opening the underlying directory reader. This allows frozen indices to be filtered with can_match and in-turn searched with wildcards in a efficient way since it allows us to exclude shards that won't match based on their date-ranges without opening their directory readers. Relates to #34352 Depends on #34357
Changes were made in elastic#34357 and elastic#36467
This change adds a
frozen
engine that allows lazily open a directory readeron a read-only shard. The engine wraps general purpose searchers in a LazyDirectoryReader
that also allows to release and reset the underlying index readers after any and before
secondary search phases.
Relates to #34352