4141import org .elasticsearch .common .unit .ByteSizeValue ;
4242import org .elasticsearch .common .unit .TimeValue ;
4343import org .elasticsearch .index .Index ;
44- import org .elasticsearch .index .IndexSettings ;
4544import org .elasticsearch .index .engine .Engine ;
4645import org .elasticsearch .index .engine .EngineException ;
4746import org .elasticsearch .index .mapper .MapperService ;
@@ -399,11 +398,7 @@ private void internalRecoverFromStore(IndexShard indexShard) throws IndexShardRe
399398 writeEmptyRetentionLeasesFile (indexShard );
400399 } else if (indexShouldExists ) {
401400 if (recoveryState .getRecoverySource ().shouldBootstrapNewHistoryUUID ()) {
402- if (IndexSettings .SKIP_FILES_RECOVERY_SETTING .get (indexShard .indexSettings ().getSettings ())) {
403- associateTranslogWithIndex (indexShard , store );
404- } else {
405- store .bootstrapNewHistory ();
406- }
401+ store .bootstrapNewHistory ();
407402 writeEmptyRetentionLeasesFile (indexShard );
408403 }
409404 // since we recover from local, just fill the files and size
@@ -465,14 +460,7 @@ private void restore(IndexShard indexShard, Repository repository, SnapshotRecov
465460 final ActionListener <Void > restoreListener = ActionListener .wrap (
466461 v -> {
467462 final Store store = indexShard .store ();
468- if (IndexSettings .SKIP_FILES_RECOVERY_SETTING .get (indexShard .indexSettings ().getSettings ())) {
469- // shard is restored from a snapshot and we expect the store to already contains the files,
470- // hence we can skip bootstraping a new history uuid with a new translog, and simply
471- // associate an empty translog with the existing lucene commit.
472- associateTranslogWithIndex (indexShard , store );
473- } else {
474- bootstrap (indexShard , store );
475- }
463+ bootstrap (indexShard , store );
476464 assert indexShard .shardRouting .primary () : "only primary shards can recover from store" ;
477465 writeEmptyRetentionLeasesFile (indexShard );
478466 indexShard .openEngineAndRecoverFromTranslog ();
@@ -503,18 +491,9 @@ private void restore(IndexShard indexShard, Repository repository, SnapshotRecov
503491 indexIdListener .onResponse (indexId );
504492 }
505493 assert indexShard .getEngineOrNull () == null ;
506- indexIdListener .whenComplete (
507- idx -> {
508- if (IndexSettings .SKIP_FILES_RECOVERY_SETTING .get (indexShard .indexSettings ().getSettings ())) {
509- logger .debug ("[{}] skipping full restore from [{}] [{}]" ,
510- shardId , restoreSource .snapshot ().getRepository (), restoreSource .snapshot ().getSnapshotId ());
511- restoreListener .onResponse (null );
512- } else {
513- repository .restoreShard (indexShard .store (), restoreSource .snapshot ().getSnapshotId (),
514- idx , snapshotShardId , indexShard .recoveryState (), restoreListener );
515- }
516- }, restoreListener ::onFailure );
517- } catch (Exception e ) {
494+ indexIdListener .whenComplete (idx -> repository .restoreShard (indexShard .store (), restoreSource .snapshot ().getSnapshotId (),
495+ idx , snapshotShardId , indexShard .recoveryState (), restoreListener ), restoreListener ::onFailure );
496+ } catch (Exception e ) {
518497 restoreListener .onFailure (e );
519498 }
520499 }
@@ -527,13 +506,4 @@ private void bootstrap(final IndexShard indexShard, final Store store) throws IO
527506 indexShard .shardPath ().resolveTranslog (), localCheckpoint , shardId , indexShard .getPendingPrimaryTerm ());
528507 store .associateIndexWithNewTranslog (translogUUID );
529508 }
530-
531- private void associateTranslogWithIndex (final IndexShard indexShard , final Store store ) throws IOException {
532- assert IndexSettings .SKIP_FILES_RECOVERY_SETTING .get (indexShard .indexSettings ().getSettings ());
533- final SegmentInfos segmentInfos = store .readLastCommittedSegmentsInfo ();
534- final long localCheckpoint = Long .parseLong (segmentInfos .userData .get (SequenceNumbers .LOCAL_CHECKPOINT_KEY ));
535- final long primaryTerm = indexShard .getPendingPrimaryTerm ();
536- final String translogUUID = segmentInfos .userData .get (Translog .TRANSLOG_UUID_KEY );
537- Translog .createEmptyTranslog (indexShard .shardPath ().resolveTranslog (), shardId , localCheckpoint , primaryTerm , translogUUID , null );
538- }
539509}
0 commit comments