Skip to content

Commit 32df1c4

Browse files
committed
Partial revert "Associate translog with Lucene index commit"
This partially reverts commit 406d4de
1 parent 406d4de commit 32df1c4

File tree

5 files changed

+7
-62
lines changed

5 files changed

+7
-62
lines changed

server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
166166
IndexSettings.FINAL_PIPELINE,
167167
MetaDataIndexStateService.VERIFIED_BEFORE_CLOSE_SETTING,
168168
IndexSettings.ON_HEAP_ID_TERMS_INDEX,
169-
IndexSettings.SKIP_FILES_RECOVERY_SETTING,
170169
ExistingShardsAllocator.EXISTING_SHARDS_ALLOCATOR_SETTING,
171170

172171
// validate that built-in similarities don't get redefined

server/src/main/java/org/elasticsearch/index/IndexSettings.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,6 @@ public final class IndexSettings {
325325
public static final Setting<Double> FILE_BASED_RECOVERY_THRESHOLD_SETTING
326326
= Setting.doubleSetting("index.recovery.file_based_threshold", 0.1d, 0.0d, Setting.Property.IndexScope);
327327

328-
/**
329-
* A badly named setting indicating that for some specific shards we skip the files recovery and assume that the
330-
* files are available.
331-
*/
332-
public static final Setting<Boolean> SKIP_FILES_RECOVERY_SETTING =
333-
Setting.boolSetting("index.recovery.skip_files", false, Setting.Property.IndexScope, Property.PrivateIndex);
334-
335328
private final Index index;
336329
private final Version version;
337330
private final Logger logger;

server/src/main/java/org/elasticsearch/index/shard/StoreRecovery.java

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.elasticsearch.common.unit.ByteSizeValue;
4242
import org.elasticsearch.common.unit.TimeValue;
4343
import org.elasticsearch.index.Index;
44-
import org.elasticsearch.index.IndexSettings;
4544
import org.elasticsearch.index.engine.Engine;
4645
import org.elasticsearch.index.engine.EngineException;
4746
import 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
}

server/src/main/java/org/elasticsearch/indices/recovery/PeerRecoveryTargetService.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.apache.logging.log4j.LogManager;
2323
import org.apache.logging.log4j.Logger;
2424
import org.apache.logging.log4j.message.ParameterizedMessage;
25-
import org.apache.lucene.index.SegmentInfos;
2625
import org.apache.lucene.store.AlreadyClosedException;
2726
import org.apache.lucene.store.RateLimiter;
2827
import org.elasticsearch.ElasticsearchException;
@@ -43,10 +42,8 @@
4342
import org.elasticsearch.common.util.CancellableThreads;
4443
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
4544
import org.elasticsearch.index.IndexNotFoundException;
46-
import org.elasticsearch.index.IndexSettings;
4745
import org.elasticsearch.index.engine.RecoveryEngineException;
4846
import org.elasticsearch.index.mapper.MapperException;
49-
import org.elasticsearch.index.seqno.SequenceNumbers;
5047
import org.elasticsearch.index.shard.IllegalIndexShardStateException;
5148
import org.elasticsearch.index.shard.IndexEventListener;
5249
import org.elasticsearch.index.shard.IndexShard;
@@ -67,7 +64,6 @@
6764
import org.elasticsearch.transport.TransportService;
6865

6966
import java.io.IOException;
70-
import java.nio.file.Path;
7167
import java.util.concurrent.atomic.AtomicLong;
7268
import java.util.function.Consumer;
7369

@@ -178,19 +174,8 @@ private void doRecovery(final long recoveryId) {
178174
try {
179175
assert recoveryTarget.sourceNode() != null : "can not do a recovery without a source node";
180176
logger.trace("{} preparing shard for peer recovery", recoveryTarget.shardId());
181-
final IndexShard indexShard = recoveryTarget.indexShard();
182-
indexShard.prepareForIndexRecovery();
183-
if (IndexSettings.SKIP_FILES_RECOVERY_SETTING.get(indexShard.indexSettings().getSettings())) {
184-
// associate a new empty translog with the last lucene commit, this way the next StartRecoveryRequest
185-
// will see shard files as if they were already on disk
186-
final SegmentInfos segmentInfos = indexShard.store().readLastCommittedSegmentsInfo();
187-
final long localCheckpoint = Long.parseLong(segmentInfos.userData.get(SequenceNumbers.LOCAL_CHECKPOINT_KEY));
188-
final long primaryTerm = indexShard.getPendingPrimaryTerm();
189-
final String translogUUID = segmentInfos.userData.get(Translog.TRANSLOG_UUID_KEY);
190-
final Path location = indexShard.shardPath().resolveTranslog();
191-
Translog.createEmptyTranslog(location, indexShard.shardId(), localCheckpoint, primaryTerm, translogUUID, null);
192-
}
193-
final long startingSeqNo = indexShard.recoverLocallyUpToGlobalCheckpoint();
177+
recoveryTarget.indexShard().prepareForIndexRecovery();
178+
final long startingSeqNo = recoveryTarget.indexShard().recoverLocallyUpToGlobalCheckpoint();
194179
assert startingSeqNo == UNASSIGNED_SEQ_NO || recoveryTarget.state().getStage() == RecoveryState.Stage.TRANSLOG :
195180
"unexpected recovery stage [" + recoveryTarget.state().getStage() + "] starting seqno [ " + startingSeqNo + "]";
196181
request = getStartRecoveryRequest(logger, clusterService.localNode(), recoveryTarget, startingSeqNo);

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/TransportMountSearchableSnapshotAction.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.elasticsearch.common.io.stream.StreamInput;
2525
import org.elasticsearch.common.settings.Settings;
2626
import org.elasticsearch.index.IndexNotFoundException;
27-
import org.elasticsearch.index.IndexSettings;
2827
import org.elasticsearch.repositories.IndexId;
2928
import org.elasticsearch.repositories.RepositoriesService;
3029
import org.elasticsearch.repositories.Repository;
@@ -96,7 +95,6 @@ private static Settings buildIndexSettings(String repoName, SnapshotId snapshotI
9695
.put(SearchableSnapshots.SNAPSHOT_SNAPSHOT_ID_SETTING.getKey(), snapshotId.getUUID())
9796
.put(SearchableSnapshots.SNAPSHOT_INDEX_ID_SETTING.getKey(), indexId.getId())
9897
.put(INDEX_STORE_TYPE_SETTING.getKey(), SearchableSnapshots.SNAPSHOT_DIRECTORY_FACTORY_KEY)
99-
.put(IndexSettings.SKIP_FILES_RECOVERY_SETTING.getKey(), true)
10098
.put(IndexMetaData.SETTING_BLOCKS_WRITE, true)
10199
.put(ExistingShardsAllocator.EXISTING_SHARDS_ALLOCATOR_SETTING.getKey(), SearchableSnapshotAllocator.ALLOCATOR_NAME)
102100
.build();

0 commit comments

Comments
 (0)