41
41
import org .elasticsearch .common .unit .ByteSizeValue ;
42
42
import org .elasticsearch .common .unit .TimeValue ;
43
43
import org .elasticsearch .index .Index ;
44
- import org .elasticsearch .index .IndexSettings ;
45
44
import org .elasticsearch .index .engine .Engine ;
46
45
import org .elasticsearch .index .engine .EngineException ;
47
46
import org .elasticsearch .index .mapper .MapperService ;
@@ -399,11 +398,7 @@ private void internalRecoverFromStore(IndexShard indexShard) throws IndexShardRe
399
398
writeEmptyRetentionLeasesFile (indexShard );
400
399
} else if (indexShouldExists ) {
401
400
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 ();
407
402
writeEmptyRetentionLeasesFile (indexShard );
408
403
}
409
404
// since we recover from local, just fill the files and size
@@ -465,14 +460,7 @@ private void restore(IndexShard indexShard, Repository repository, SnapshotRecov
465
460
final ActionListener <Void > restoreListener = ActionListener .wrap (
466
461
v -> {
467
462
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 );
476
464
assert indexShard .shardRouting .primary () : "only primary shards can recover from store" ;
477
465
writeEmptyRetentionLeasesFile (indexShard );
478
466
indexShard .openEngineAndRecoverFromTranslog ();
@@ -503,18 +491,9 @@ private void restore(IndexShard indexShard, Repository repository, SnapshotRecov
503
491
indexIdListener .onResponse (indexId );
504
492
}
505
493
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 ) {
518
497
restoreListener .onFailure (e );
519
498
}
520
499
}
@@ -527,13 +506,4 @@ private void bootstrap(final IndexShard indexShard, final Store store) throws IO
527
506
indexShard .shardPath ().resolveTranslog (), localCheckpoint , shardId , indexShard .getPendingPrimaryTerm ());
528
507
store .associateIndexWithNewTranslog (translogUUID );
529
508
}
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
- }
539
509
}
0 commit comments