-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Track evacuated IDs since the last shard-local refresh in LiveVersionMap #95331
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
pxsalehi
merged 26 commits into
elastic:main
from
pxsalehi:ps230417-LiveVersionMap-archiver
May 4, 2023
Merged
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
e04e324
first draft
pxsalehi f83cabe
prioratize tombstone read over archiver read
pxsalehi e83cff3
renames and an assert
pxsalehi c41d7ab
comments
pxsalehi f4fb8da
Merge remote-tracking branch 'upstream/main' into ps230417-LiveVersio…
pxsalehi f1986b0
cleanup and make a bunch of stuff public
pxsalehi 8629e47
use archiver only for non-assert map
pxsalehi 3d3536b
clear archive if unsafe
pxsalehi 1bab205
translogOnly get
pxsalehi c372b85
Revert "translogOnly get"
pxsalehi f8bf812
make stuff public for testing
pxsalehi b450b6f
translogOnly get
pxsalehi 831dc9f
clear archive when swithing from unsafe to safe
pxsalehi 71fda19
remove clear archive
pxsalehi b147487
comments
pxsalehi 9448f49
Revert "translogOnly get"
pxsalehi 0cc9ba2
move some unsued stuff back to package private visibility
pxsalehi 1c2aa67
reduce chaos
pxsalehi 638b3db
clean up modifiers and add comments
pxsalehi d69e55b
spotless
pxsalehi 331dfc6
Merge remote-tracking branch 'upstream/main' into ps230417-LiveVersio…
pxsalehi d2b9623
clean up and track min delete timestamp
pxsalehi 6e169b2
address review comments
pxsalehi 1848177
add more test
pxsalehi 344c81d
protected
pxsalehi 7acd078
Merge remote-tracking branch 'upstream/main' into ps230417-LiveVersio…
pxsalehi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
server/src/main/java/org/elasticsearch/index/engine/LiveVersionMapArchiver.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.index.engine; | ||
|
||
import org.apache.lucene.util.BytesRef; | ||
|
||
/** | ||
* Keeps track of the old map of a LiveVersionMap that gets evacuated on a refresh | ||
*/ | ||
public interface LiveVersionMapArchiver { | ||
pxsalehi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* Archive the old map evacuated due to a refresh | ||
* | ||
* @param old is the old map that is evacuated on a refresh | ||
*/ | ||
void afterRefresh(LiveVersionMap.VersionLookup old); | ||
|
||
/** | ||
* Trigger a cleanup of the archive based on the given generation | ||
* | ||
* @param generation the generation of the commit caused by the flush | ||
*/ | ||
void afterUnpromotablesRefreshed(long generation); | ||
pxsalehi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Look up the given uid in the archive | ||
*/ | ||
VersionValue get(BytesRef uid); | ||
|
||
LiveVersionMapArchiver NOOP_ARCHIVER = new LiveVersionMapArchiver() { | ||
@Override | ||
public void afterRefresh(LiveVersionMap.VersionLookup old) {} | ||
|
||
@Override | ||
public void afterUnpromotablesRefreshed(long generation) {} | ||
|
||
@Override | ||
public VersionValue get(BytesRef uid) { | ||
return null; | ||
} | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
server/src/test/java/org/elasticsearch/index/engine/LiveVersionMapTestUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.index.engine; | ||
|
||
import org.apache.lucene.index.Term; | ||
import org.apache.lucene.util.BytesRef; | ||
import org.apache.lucene.util.BytesRefBuilder; | ||
import org.elasticsearch.core.Releasable; | ||
import org.elasticsearch.index.mapper.IdFieldMapper; | ||
import org.elasticsearch.index.mapper.Uid; | ||
|
||
public class LiveVersionMapTestUtils { | ||
pxsalehi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public static VersionValue get(LiveVersionMap map, String id) { | ||
try (Releasable r = acquireLock(map, uid(id))) { | ||
return map.getUnderLock(uid(id)); | ||
} | ||
} | ||
|
||
public static void putIndex(LiveVersionMap map, String id, IndexVersionValue version) { | ||
try (Releasable r = acquireLock(map, uid(id))) { | ||
map.putIndexUnderLock(uid(id), version); | ||
} | ||
} | ||
|
||
public static void putDelete(LiveVersionMap map, String id, DeleteVersionValue version) { | ||
try (Releasable r = acquireLock(map, uid(id))) { | ||
map.putDeleteUnderLock(uid(id), version); | ||
} | ||
} | ||
|
||
public static void pruneTombstones(LiveVersionMap map, long maxTimestampToPrune, long maxSeqNoToPrune) { | ||
map.pruneTombstones(maxTimestampToPrune, maxSeqNoToPrune); | ||
} | ||
|
||
public static int VersionLookupSize(LiveVersionMap.VersionLookup lookup) { | ||
return lookup.size(); | ||
} | ||
|
||
private static Releasable acquireLock(LiveVersionMap map, BytesRef uid) { | ||
return map.acquireLock(uid); | ||
} | ||
|
||
private static BytesRef uid(String id) { | ||
return new Term(IdFieldMapper.NAME, Uid.encodeId(id)).bytes(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.