-
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
Lazily load soft-deletes for searchable snapshot shards #69203
Conversation
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.
This class makes sense for searchable snapshots. I've left some small comments.
server/src/main/java/org/apache/lucene/index/LazySoftDeletesDirectoryReaderWrapper.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/lucene/index/LazySoftDeletesDirectoryReaderWrapper.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/lucene/index/LazySoftDeletesDirectoryReaderWrapper.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/lucene/index/LazySoftDeletesDirectoryReaderWrapper.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/lucene/index/LazySoftDeletesDirectoryReaderWrapper.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/lucene/index/LazySoftDeletesDirectoryReaderWrapper.java
Outdated
Show resolved
Hide resolved
Pinging @elastic/es-distributed (Team:Distributed) |
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.
LGTM with smaller comments. Thanks Yannick!
server/src/main/java/org/apache/lucene/index/LazySoftDeletesDirectoryReaderWrapper.java
Show resolved
Hide resolved
server/src/main/java/org/apache/lucene/index/LazySoftDeletesDirectoryReaderWrapper.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/engine/ReadOnlyEngine.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/lucene/index/LazySoftDeletesDirectoryReaderWrapper.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/lucene/index/LazySoftDeletesDirectoryReaderWrapper.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
private static class DelegatingCacheHelper implements CacheHelper { |
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 believe that this bit is the only reason why we need to have this class in the oal.index
package. Can we find a way to avoid doing cross-JAR package-protected access? (Is there another option than making the CacheKey ctor public?)
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.
The only other reason except for CacheKey
is the call to the PendingSoftDeletes.applySoftDeletes
method. That method can easily be reimplemented, however. I don't see a good way to work around the CacheKey
constructor not being accessible (safe for introducing even more outrageous hacks), and FWIW we already have some classes like ShuffleForcedMergePolicy
and OneMergeHelper
in this package.
@elasticmachine update branch (test failure unrelated) |
@elasticmachine run elasticsearch-ci/1 (yet another unrelated test failure ...) |
Opening a Lucene index that supports soft-deletes currently creates the liveDocs bitset eagerly. This requires scanning the doc values to materialize the liveDocs bitset from the soft-delete doc values. In order for searchable snapshot shards to be available for searches as quickly as possible (i.e. on recovery, or in case of FrozenEngine whenever a search comes in), they should read as little as possible from the Lucene files. This commit introduces a LazySoftDeletesDirectoryReaderWrapper, a variant of Lucene's SoftDeletesDirectoryReaderWrapper that loads the livedocs bitset lazily on first access. It is special-tailored to ReadOnlyEngine / FrozenEngine as it only operates on non-NRT readers.
Opening a Lucene index that supports soft-deletes currently creates the liveDocs bitset eagerly. This requires scanning the doc values to materialize the liveDocs bitset from the soft-delete doc values. In order for searchable snapshot shards to be available for searches as quickly as possible (i.e. on recovery, or in case of FrozenEngine whenever a search comes in), they should read as little as possible from the Lucene files. This commit introduces a LazySoftDeletesDirectoryReaderWrapper, a variant of Lucene's SoftDeletesDirectoryReaderWrapper that loads the livedocs bitset lazily on first access. It is special-tailored to ReadOnlyEngine / FrozenEngine as it only operates on non-NRT readers.
Opening a Lucene index that supports soft-deletes currently creates the liveDocs bitset eagerly. This requires scanning the doc values to materialize the liveDocs bitset from the soft-delete doc values. In order for searchable snapshot shards to be available for searches as quickly as possible (i.e. on recovery, or in case of
FrozenEngine
whenever a search comes in), they should read as little as possible from the Lucene files.This PR introduces a
LazySoftDeletesDirectoryReaderWrapper
, a variant of Lucene'sSoftDeletesDirectoryReaderWrapper
that loads the livedocs bitset lazily on first access. It is special-tailored toReadOnlyEngine
/FrozenEngine
as it only operates on non-NRT readers.