-
Notifications
You must be signed in to change notification settings - Fork 25.4k
Make peer recovery work with archive data #81522
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
Changes from all commits
8f5020f
3383a62
8af1fdb
5a164e7
690c590
46373dd
4a2cd8c
984aed9
2c23228
8433518
396cadc
0286c9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
import org.apache.lucene.index.Terms; | ||
import org.apache.lucene.store.Directory; | ||
import org.apache.lucene.store.IOContext; | ||
import org.elasticsearch.index.mapper.SeqNoFieldMapper; | ||
import org.elasticsearch.xpack.lucene.bwc.codecs.lucene70.BWCLucene70Codec; | ||
|
||
import java.io.IOException; | ||
|
@@ -169,6 +170,10 @@ public void write(Directory directory, SegmentInfo segmentInfo, String segmentSu | |
private static FieldInfos filterFields(FieldInfos fieldInfos) { | ||
List<FieldInfo> fieldInfoCopy = new ArrayList<>(fieldInfos.size()); | ||
for (FieldInfo fieldInfo : fieldInfos) { | ||
// omit sequence number field so that it doesn't interfere with peer recovery | ||
if (fieldInfo.name.equals(SeqNoFieldMapper.NAME)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this, In a follow-up, I want to explore exposing doc-values of older indices (in particular _seq_no field and soft-deletes) |
||
continue; | ||
} | ||
fieldInfoCopy.add( | ||
new FieldInfo( | ||
fieldInfo.name, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.apache.logging.log4j.message.ParameterizedMessage; | ||
import org.apache.lucene.index.SegmentInfos; | ||
import org.elasticsearch.action.StepListener; | ||
import org.elasticsearch.cluster.node.DiscoveryNode; | ||
import org.elasticsearch.cluster.routing.RecoverySource; | ||
|
@@ -18,20 +17,15 @@ | |
import org.elasticsearch.core.Nullable; | ||
import org.elasticsearch.index.IndexService; | ||
import org.elasticsearch.index.IndexSettings; | ||
import org.elasticsearch.index.seqno.SequenceNumbers; | ||
import org.elasticsearch.index.shard.IndexEventListener; | ||
import org.elasticsearch.index.shard.IndexShard; | ||
import org.elasticsearch.index.shard.ShardId; | ||
import org.elasticsearch.index.translog.Translog; | ||
import org.elasticsearch.index.translog.TranslogException; | ||
import org.elasticsearch.indices.cluster.IndicesClusterStateService.AllocatedIndices.IndexRemovalReason; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.xpack.searchablesnapshots.cache.full.CacheService; | ||
import org.elasticsearch.xpack.searchablesnapshots.cache.shared.FrozenCacheService; | ||
import org.elasticsearch.xpack.searchablesnapshots.store.SearchableSnapshotDirectory; | ||
|
||
import java.nio.file.Path; | ||
|
||
import static org.elasticsearch.snapshots.SearchableSnapshotsSettings.isSearchableSnapshotStore; | ||
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshots.SNAPSHOT_INDEX_NAME_SETTING; | ||
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshots.SNAPSHOT_SNAPSHOT_ID_SETTING; | ||
|
@@ -65,7 +59,6 @@ public SearchableSnapshotIndexEventListener( | |
public void beforeIndexShardRecovery(IndexShard indexShard, IndexSettings indexSettings) { | ||
assert Thread.currentThread().getName().contains(ThreadPool.Names.GENERIC); | ||
ensureSnapshotIsLoaded(indexShard); | ||
associateNewEmptyTranslogWithIndex(indexShard); | ||
} | ||
|
||
private static void ensureSnapshotIsLoaded(IndexShard indexShard) { | ||
|
@@ -93,26 +86,6 @@ private static void ensureSnapshotIsLoaded(IndexShard indexShard) { | |
: "loading snapshot must not be called twice unless we are retrying a peer recovery"; | ||
} | ||
|
||
private static void associateNewEmptyTranslogWithIndex(IndexShard indexShard) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is now gone. Woop woop |
||
final ShardId shardId = indexShard.shardId(); | ||
assert isSearchableSnapshotStore(indexShard.indexSettings().getSettings()) : "Expected a searchable snapshot shard " + shardId; | ||
if (indexShard.routingEntry().primary() | ||
&& indexShard.routingEntry().recoverySource().getType().equals(RecoverySource.Type.SNAPSHOT)) { | ||
// translog initialization is done later in the restore step | ||
return; | ||
} | ||
try { | ||
final SegmentInfos segmentInfos = indexShard.store().readLastCommittedSegmentsInfo(); | ||
final long localCheckpoint = Long.parseLong(segmentInfos.userData.get(SequenceNumbers.LOCAL_CHECKPOINT_KEY)); | ||
final long primaryTerm = indexShard.getPendingPrimaryTerm(); | ||
final String translogUUID = segmentInfos.userData.get(Translog.TRANSLOG_UUID_KEY); | ||
final Path translogLocation = indexShard.shardPath().resolveTranslog(); | ||
Translog.createEmptyTranslog(translogLocation, shardId, localCheckpoint, primaryTerm, translogUUID, null); | ||
} catch (Exception e) { | ||
throw new TranslogException(shardId, "failed to associate a new translog", e); | ||
} | ||
} | ||
|
||
@Override | ||
public void beforeIndexRemoved(IndexService indexService, IndexRemovalReason reason) { | ||
if (shouldEvictCacheFiles(reason)) { | ||
|
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.
With this new approach, we now have sequence-number based recoveries for searchable snapshots, which means that there's no need any longer to send over any file (i.e. the exception of
^recovery\..*\.segments_.*$
inInMemoryNoOpCommitDirectory.ensureMutable
) except for the BWC case (when primary was on older node and created a different history uuid).