-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Move trimming unsafe commits from the Engine constructor to Store #29260
Conversation
# Conflicts: # docs/reference/indices/flush.asciidoc # server/src/main/java/org/elasticsearch/index/engine/EngineDiskUtils.java # server/src/main/java/org/elasticsearch/index/shard/IndexShard.java # server/src/test/java/org/elasticsearch/index/engine/EngineDiskUtilsTests.java
…_unsafe # Conflicts: # server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java # server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
Pinging @elastic/es-distributed |
@@ -93,12 +93,12 @@ which returns something similar to: | |||
{ | |||
"commit" : { | |||
"id" : "3M3zkw2GHMo2Y4h4/KFKCg==", | |||
"generation" : 4, |
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 one was tricky to trace - using a starting commit Lucene, immediately increments the pending changes counter, which means that the flush issued in the docs will actually cause a commit in Lucene. Now that we don't use a starting commit, the uncommittedChanges counter in Lucene stays 0 when opening the engine and the flush in the docs becomes a noop.
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 I think it's good to make as many decisions as possible before we create the engine!
// note that we can't just use IndexCommit.delete() as we really want to make sure that those files won't be used | ||
// even if a virus scanner causes the files not to be used. | ||
|
||
// TODO: speak to @s1monw about the fact that we can' use getUserData(writer) as that uses that last's commit user |
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.
if you open an IW based on a commit it will use that commits user data if you use getUserData(writer)
are you sure that is not the case. I just looked at the code and it looks correct
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.
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
The new commit will use segment files from the starting commit but userData from the last commit by default. Therefore we need to manually set the userData from the starting commit to the new commit.
metadataLock.writeLock().lock(); | ||
try { | ||
final List<IndexCommit> existingCommits = DirectoryReader.listCommits(directory); | ||
if (existingCommits.size() == 0) { |
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.
nit: use isEmpty()
?
@@ -1329,6 +1329,9 @@ private void innerOpenEngineAndTranslog() throws IOException { | |||
|
|||
assertMaxUnsafeAutoIdInCommit(); | |||
|
|||
final long minRetainedTranslogGen = Translog.readMinTranslogGeneration(translogConfig.getTranslogPath(), translogUUID); | |||
store.trimUnsafeCommits(globalCheckpoint, minRetainedTranslogGen, config.getIndexSettings().getIndexVersionCreated()); |
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.
👍
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.
// note that we can't just use IndexCommit.delete() as we really want to make sure that those files won't be used | ||
// even if a virus scanner causes the files not to be used. | ||
|
||
// TODO: speak to @s1monw about the fact that we can' use getUserData(writer) as that uses that last's commit user |
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.
# Conflicts: # server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java
As follow up to #28245 , this PR removes the logic for selecting the right start commit from the Engine constructor in favor of explicitly trimming them in the Store, before the engine is opened. This makes the constructor in engine follow standard Lucene semantics and use the last commit. Relates #28245 Relates #29156
* master: (80 commits) Remove HTTP max content length leniency (elastic#29337) Begin moving XContent to a separate lib/artifact (elastic#29300) Java versions for ci (elastic#29320) Minor cleanup in the InternalEngine (elastic#29241) Clarify expectations of false positives/negatives (elastic#27964) Update docs on vertex ordering (elastic#27963) Revert "REST high-level client: add support for Indices Update Settings API (elastic#28892)" (elastic#29323) [test] remove Streamable serde assertions (elastic#29307) Improve query string docs (elastic#28882) fix query string example for boolean query (elastic#28881) Resolve unchecked cast warnings introduced with elastic#28892 REST high-level client: add support for Indices Update Settings API (elastic#28892) Search: Validate script query is run with a single script (elastic#29304) [DOCS] Added info on WGS-84. Closes issue elastic#3590 (elastic#29305) Increase timeout on Netty client latch for tests Build: Use branch specific refspec sysprop for bwc builds (elastic#29299) TEST: trim unsafe commits before opening engine Move trimming unsafe commits from engine ctor to store (elastic#29260) Fix incorrect geohash for lat 90, lon 180 (elastic#29256) Do not load global state when deleting a snapshot (elastic#29278) ...
As follow up to #28245 , this PR removes the logic for selecting the right start commit from the Engine constructor in favor of explicitly trimming them in the
Store
, before the engine is opened. This makes the constructor in engine follow standard Lucene semantics and use the last commit.