Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 0631620

Browse files
committed
Enhance searchable snapshots to enable a read-only view of older snapshots (opensearch-project#5429)
* Enhance searchable snapshots to enable a read-only view of older snapshots This change removes the guardrails around N-1 backward compatibility and uses Lucene's "expert" APIs to read snapshots (Lucene segments) older than N-1 on a best-effort basis. The functionality is gated by an additional feature flag, separate from the searchable snapshots flag. Note that the Lucene integration is rather inefficient because the necessary "expert" Lucene APIs are still package-private. Signed-off-by: Kartik Ganesh <[email protected]> * Added some unit tests This change also includes a test index ZIP file for the unit tests. The change also introduces a bug fix in the readAnySegmentsInfo method to close the reader before returning the SegmentInfos object - this avoids dangling/open file handles. Signed-off-by: Kartik Ganesh <[email protected]> * Incorporating PR feedback Signed-off-by: Kartik Ganesh <[email protected]> * Incorporate PR comments from andrross Signed-off-by: Kartik Ganesh <[email protected]> * Remove use of IndexSetting for minimum version for snapshots backwards compatibility Signed-off-by: Kartik Ganesh <[email protected]> * Moved ES 6.3.0 test data to a subdirectory This change also includes an update to the file name to clarify that it is an ES index, and changing the associated markdown file name to just README.md. All tests that reference this ZIP file have corresponding changes to the path they reference. Signed-off-by: Kartik Ganesh <[email protected]> * Update unit tests to use try-with-resources Signed-off-by: Kartik Ganesh <[email protected]> * Added FeatureFlagSetter helper class Also refactored unit test classes to use the helper class. Signed-off-by: Kartik Ganesh <[email protected]> * Incorporating PR feedback from @mch2 Signed-off-by: Kartik Ganesh <[email protected]> * Fix IndexSettingsTests Updated the asserts in IndexSettingsTests to account for the new defaulting behavior. Signed-off-by: Kartik Ganesh <[email protected]> Signed-off-by: Kartik Ganesh <[email protected]>
1 parent b71caae commit 0631620

File tree

28 files changed

+555
-86
lines changed

28 files changed

+555
-86
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2727
- Add support for discovered cluster manager and remove local weights ([#5680](https://github.com/opensearch-project/OpenSearch/pull/5680))
2828
- Added support for feature flags in opensearch.yml ([#4959](https://github.com/opensearch-project/OpenSearch/pull/4959))
2929
- Add query for initialized extensions ([#5658](https://github.com/opensearch-project/OpenSearch/pull/5658))
30+
- Experimental support for extended backward compatiblity in searchable snapshots ([#5429](https://github.com/opensearch-project/OpenSearch/pull/5429))
3031

3132
### Dependencies
3233
- Bumps `log4j-core` from 2.18.0 to 2.19.0

server/src/main/java/org/opensearch/cluster/block/ClusterBlocks.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,7 @@ public Builder addBlocks(IndexMetadata indexMetadata) {
401401
if (IndexMetadata.INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING.get(indexMetadata.getSettings())) {
402402
addIndexBlock(indexName, IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK);
403403
}
404-
if (IndexModule.Type.REMOTE_SNAPSHOT.getSettingsKey()
405-
.equals(indexMetadata.getSettings().get(IndexModule.INDEX_STORE_TYPE_SETTING.getKey()))) {
404+
if (IndexModule.Type.REMOTE_SNAPSHOT.match(indexMetadata.getSettings().get(IndexModule.INDEX_STORE_TYPE_SETTING.getKey()))) {
406405
addIndexBlock(indexName, IndexMetadata.REMOTE_READ_ONLY_ALLOW_DELETE);
407406
}
408407
return this;

server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1840,10 +1840,11 @@ public static IndexMetadata fromXContent(XContentParser parser) throws IOExcepti
18401840
throw new IllegalArgumentException("Unexpected token " + token);
18411841
}
18421842
}
1843-
if (Assertions.ENABLED) {
1843+
// Reference:
1844+
// https://github.com/opensearch-project/OpenSearch/blob/4dde0f2a3b445b2fc61dab29c5a2178967f4a3e3/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java#L1620-L1628
1845+
Version legacyVersion = LegacyESVersion.fromId(6050099);
1846+
if (Assertions.ENABLED && Version.indexCreated(builder.settings).onOrAfter(legacyVersion)) {
18441847
assert mappingVersion : "mapping version should be present for indices";
1845-
}
1846-
if (Assertions.ENABLED) {
18471848
assert settingsVersion : "settings version should be present for indices";
18481849
}
18491850
if (Assertions.ENABLED) {

server/src/main/java/org/opensearch/cluster/routing/RoutingPool.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static RoutingPool getShardPool(ShardRouting shard, RoutingAllocation all
6161
*/
6262
public static RoutingPool getIndexPool(IndexMetadata indexMetadata) {
6363
Settings indexSettings = indexMetadata.getSettings();
64-
if (IndexModule.Type.REMOTE_SNAPSHOT.getSettingsKey().equals(indexSettings.get(IndexModule.INDEX_STORE_TYPE_SETTING.getKey()))) {
64+
if (IndexModule.Type.REMOTE_SNAPSHOT.match(indexSettings.get(IndexModule.INDEX_STORE_TYPE_SETTING.getKey()))) {
6565
return REMOTE_CAPABLE;
6666
}
6767
return LOCAL_ONLY;

server/src/main/java/org/opensearch/common/lucene/Lucene.java

+19
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,25 @@ public static SegmentInfos readSegmentInfos(Directory directory) throws IOExcept
134134
return SegmentInfos.readLatestCommit(directory);
135135
}
136136

137+
/**
138+
* A variant of {@link #readSegmentInfos(Directory)} that supports reading indices written by
139+
* older major versions of Lucene. The underlying implementation is a workaround since the
140+
* "expert" readLatestCommit API is currently package-private in Lucene. First, all commits in
141+
* the given {@link Directory} are listed - this result includes older Lucene commits. Then,
142+
* the latest index commit is opened via {@link DirectoryReader} by including a minimum supported
143+
* Lucene major version based on the minimum compatibility of the given {@link org.opensearch.Version}.
144+
*/
145+
public static SegmentInfos readSegmentInfosExtendedCompatibility(Directory directory, org.opensearch.Version minimumVersion)
146+
throws IOException {
147+
// This list is sorted from oldest to latest
148+
List<IndexCommit> indexCommits = DirectoryReader.listCommits(directory);
149+
IndexCommit latestCommit = indexCommits.get(indexCommits.size() - 1);
150+
final int minSupportedLuceneMajor = minimumVersion.minimumIndexCompatibilityVersion().luceneVersion.major;
151+
try (StandardDirectoryReader reader = (StandardDirectoryReader) DirectoryReader.open(latestCommit, minSupportedLuceneMajor, null)) {
152+
return reader.getSegmentInfos();
153+
}
154+
}
155+
137156
/**
138157
* Returns an iterable that allows to iterate over all files in this segments info
139158
*/

server/src/main/java/org/opensearch/common/util/FeatureFlags.java

+7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ public class FeatureFlags {
4141
*/
4242
public static final String SEARCHABLE_SNAPSHOT = "opensearch.experimental.feature.searchable_snapshot.enabled";
4343

44+
/**
45+
* Gates the ability for Searchable Snapshots to read snapshots that are older than the
46+
* guaranteed backward compatibility for OpenSearch (one prior major version) on a best effort basis.
47+
*/
48+
public static final String SEARCHABLE_SNAPSHOT_EXTENDED_COMPATIBILITY =
49+
"opensearch.experimental.feature.searchable_snapshot.extended_compatibility.enabled";
50+
4451
/**
4552
* Gates the functionality of extensions.
4653
* Once the feature is ready for production release, this feature flag can be removed.

server/src/main/java/org/opensearch/index/IndexModule.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,19 @@ public boolean match(String setting) {
461461
}
462462

463463
/**
464-
* Convenience method to check whether the given IndexSettings contains
465-
* an {@link #INDEX_STORE_TYPE_SETTING} set to the value of this type.
464+
* Convenience method to check whether the given {@link IndexSettings}
465+
* object contains an {@link #INDEX_STORE_TYPE_SETTING} set to the value of this type.
466466
*/
467467
public boolean match(IndexSettings settings) {
468-
return match(INDEX_STORE_TYPE_SETTING.get(settings.getSettings()));
468+
return match(settings.getSettings());
469+
}
470+
471+
/**
472+
* Convenience method to check whether the given {@link Settings}
473+
* object contains an {@link #INDEX_STORE_TYPE_SETTING} set to the value of this type.
474+
*/
475+
public boolean match(Settings settings) {
476+
return match(INDEX_STORE_TYPE_SETTING.get(settings));
469477
}
470478
}
471479

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

+30
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.opensearch.common.unit.ByteSizeUnit;
4646
import org.opensearch.common.unit.ByteSizeValue;
4747
import org.opensearch.common.unit.TimeValue;
48+
import org.opensearch.common.util.FeatureFlags;
4849
import org.opensearch.index.translog.Translog;
4950
import org.opensearch.indices.replication.common.ReplicationType;
5051
import org.opensearch.ingest.IngestService;
@@ -59,11 +60,13 @@
5960
import java.util.function.Function;
6061
import java.util.function.UnaryOperator;
6162

63+
import static org.opensearch.common.util.FeatureFlags.SEARCHABLE_SNAPSHOT_EXTENDED_COMPATIBILITY;
6264
import static org.opensearch.index.mapper.MapperService.INDEX_MAPPING_DEPTH_LIMIT_SETTING;
6365
import static org.opensearch.index.mapper.MapperService.INDEX_MAPPING_FIELD_NAME_LENGTH_LIMIT_SETTING;
6466
import static org.opensearch.index.mapper.MapperService.INDEX_MAPPING_NESTED_DOCS_LIMIT_SETTING;
6567
import static org.opensearch.index.mapper.MapperService.INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING;
6668
import static org.opensearch.index.mapper.MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING;
69+
import static org.opensearch.index.store.remote.directory.RemoteSnapshotDirectory.SEARCHABLE_SNAPSHOT_EXTENDED_COMPATIBILITY_MINIMUM_VERSION;
6770

6871
/**
6972
* This class encapsulates all index level settings and handles settings updates.
@@ -585,6 +588,9 @@ public final class IndexSettings {
585588
private final boolean isRemoteTranslogStoreEnabled;
586589
private final String remoteStoreTranslogRepository;
587590
private final String remoteStoreRepository;
591+
private final boolean isRemoteSnapshot;
592+
private Version extendedCompatibilitySnapshotVersion;
593+
588594
// volatile fields are updated via #updateIndexMetadata(IndexMetadata) under lock
589595
private volatile Settings settings;
590596
private volatile IndexMetadata indexMetadata;
@@ -748,6 +754,14 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
748754
isRemoteTranslogStoreEnabled = settings.getAsBoolean(IndexMetadata.SETTING_REMOTE_TRANSLOG_STORE_ENABLED, false);
749755
remoteStoreTranslogRepository = settings.get(IndexMetadata.SETTING_REMOTE_TRANSLOG_STORE_REPOSITORY);
750756
remoteStoreRepository = settings.get(IndexMetadata.SETTING_REMOTE_STORE_REPOSITORY);
757+
isRemoteSnapshot = IndexModule.Type.REMOTE_SNAPSHOT.match(this.settings);
758+
759+
if (isRemoteSnapshot && FeatureFlags.isEnabled(SEARCHABLE_SNAPSHOT_EXTENDED_COMPATIBILITY)) {
760+
extendedCompatibilitySnapshotVersion = SEARCHABLE_SNAPSHOT_EXTENDED_COMPATIBILITY_MINIMUM_VERSION;
761+
} else {
762+
extendedCompatibilitySnapshotVersion = Version.CURRENT.minimumIndexCompatibilityVersion();
763+
}
764+
751765
this.searchThrottled = INDEX_SEARCH_THROTTLED.get(settings);
752766
this.queryStringLenient = QUERY_STRING_LENIENT_SETTING.get(settings);
753767
this.queryStringAnalyzeWildcard = QUERY_STRING_ANALYZE_WILDCARD.get(nodeSettings);
@@ -1017,6 +1031,22 @@ public String getRemoteStoreTranslogRepository() {
10171031
return remoteStoreTranslogRepository;
10181032
}
10191033

1034+
/**
1035+
* Returns true if this is remote/searchable snapshot
1036+
*/
1037+
public boolean isRemoteSnapshot() {
1038+
return isRemoteSnapshot;
1039+
}
1040+
1041+
/**
1042+
* If this is a remote snapshot and the extended compatibility
1043+
* feature flag is enabled, this returns the minimum {@link Version}
1044+
* supported. In all other cases, the return value is null.
1045+
*/
1046+
public Version getExtendedCompatibilitySnapshotVersion() {
1047+
return extendedCompatibilitySnapshotVersion;
1048+
}
1049+
10201050
/**
10211051
* Returns the node settings. The settings returned from {@link #getSettings()} are a merged version of the
10221052
* index settings and the node settings where node settings are overwritten by index settings.

server/src/main/java/org/opensearch/index/engine/ReadOnlyEngine.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public class ReadOnlyEngine extends Engine {
8989
private final CompletionStatsCache completionStatsCache;
9090
private final boolean requireCompleteHistory;
9191
private final TranslogManager translogManager;
92+
private final Version minimumSupportedVersion;
9293

9394
protected volatile TranslogStats translogStats;
9495

@@ -115,6 +116,8 @@ public ReadOnlyEngine(
115116
) {
116117
super(config);
117118
this.requireCompleteHistory = requireCompleteHistory;
119+
// fetch the minimum Version for extended backward compatibility use-cases
120+
this.minimumSupportedVersion = config.getIndexSettings().getExtendedCompatibilitySnapshotVersion();
118121
try {
119122
Store store = config.getStore();
120123
store.incRef();
@@ -126,7 +129,11 @@ public ReadOnlyEngine(
126129
// we obtain the IW lock even though we never modify the index.
127130
// yet this makes sure nobody else does. including some testing tools that try to be messy
128131
indexWriterLock = obtainLock ? directory.obtainLock(IndexWriter.WRITE_LOCK_NAME) : null;
129-
this.lastCommittedSegmentInfos = Lucene.readSegmentInfos(directory);
132+
if (isExtendedCompatibility()) {
133+
this.lastCommittedSegmentInfos = Lucene.readSegmentInfosExtendedCompatibility(directory, this.minimumSupportedVersion);
134+
} else {
135+
this.lastCommittedSegmentInfos = Lucene.readSegmentInfos(directory);
136+
}
130137
if (seqNoStats == null) {
131138
seqNoStats = buildSeqNoStats(config, lastCommittedSegmentInfos);
132139
ensureMaxSeqNoEqualsToGlobalCheckpoint(seqNoStats);
@@ -215,7 +222,17 @@ protected final OpenSearchDirectoryReader wrapReader(
215222

216223
protected DirectoryReader open(IndexCommit commit) throws IOException {
217224
assert Transports.assertNotTransportThread("opening index commit of a read-only engine");
218-
return new SoftDeletesDirectoryReaderWrapper(DirectoryReader.open(commit), Lucene.SOFT_DELETES_FIELD);
225+
DirectoryReader reader;
226+
if (isExtendedCompatibility()) {
227+
reader = DirectoryReader.open(commit, this.minimumSupportedVersion.luceneVersion.major, null);
228+
} else {
229+
reader = DirectoryReader.open(commit);
230+
}
231+
return new SoftDeletesDirectoryReaderWrapper(reader, Lucene.SOFT_DELETES_FIELD);
232+
}
233+
234+
private boolean isExtendedCompatibility() {
235+
return Version.CURRENT.minimumIndexCompatibilityVersion().onOrAfter(this.minimumSupportedVersion);
219236
}
220237

221238
@Override

server/src/main/java/org/opensearch/index/shard/IndexShard.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -2067,7 +2067,7 @@ public void openEngineAndRecoverFromTranslog() throws IOException {
20672067
};
20682068

20692069
// Do not load the global checkpoint if this is a remote snapshot index
2070-
if (IndexModule.Type.REMOTE_SNAPSHOT.match(indexSettings) == false) {
2070+
if (indexSettings.isRemoteSnapshot() == false) {
20712071
loadGlobalCheckpointToReplicationTracker();
20722072
}
20732073

@@ -2126,7 +2126,7 @@ private void innerOpenEngineAndTranslog(LongSupplier globalCheckpointSupplier) t
21262126
}
21272127

21282128
private boolean assertSequenceNumbersInCommit() throws IOException {
2129-
final Map<String, String> userData = SegmentInfos.readLatestCommit(store.directory()).getUserData();
2129+
final Map<String, String> userData = fetchUserData();
21302130
assert userData.containsKey(SequenceNumbers.LOCAL_CHECKPOINT_KEY) : "commit point doesn't contains a local checkpoint";
21312131
assert userData.containsKey(MAX_SEQ_NO) : "commit point doesn't contains a maximum sequence number";
21322132
assert userData.containsKey(Engine.HISTORY_UUID_KEY) : "commit point doesn't contains a history uuid";
@@ -2141,6 +2141,16 @@ private boolean assertSequenceNumbersInCommit() throws IOException {
21412141
return true;
21422142
}
21432143

2144+
private Map<String, String> fetchUserData() throws IOException {
2145+
if (indexSettings.isRemoteSnapshot() && indexSettings.getExtendedCompatibilitySnapshotVersion() != null) {
2146+
// Inefficient method to support reading old Lucene indexes
2147+
return Lucene.readSegmentInfosExtendedCompatibility(store.directory(), indexSettings.getExtendedCompatibilitySnapshotVersion())
2148+
.getUserData();
2149+
} else {
2150+
return SegmentInfos.readLatestCommit(store.directory()).getUserData();
2151+
}
2152+
}
2153+
21442154
private void onNewEngine(Engine newEngine) {
21452155
assert Thread.holdsLock(engineMutex);
21462156
refreshListeners.setCurrentRefreshLocationSupplier(newEngine.translogManager()::getTranslogLastWriteLocation);

server/src/main/java/org/opensearch/index/store/Store.java

+28-2
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,21 @@ public Directory directory() {
221221
public SegmentInfos readLastCommittedSegmentsInfo() throws IOException {
222222
failIfCorrupted();
223223
try {
224-
return readSegmentsInfo(null, directory());
224+
if (indexSettings.isRemoteSnapshot() && indexSettings.getExtendedCompatibilitySnapshotVersion() != null) {
225+
return readSegmentInfosExtendedCompatibility(directory(), indexSettings.getExtendedCompatibilitySnapshotVersion());
226+
} else {
227+
return readSegmentsInfo(null, directory());
228+
}
225229
} catch (CorruptIndexException | IndexFormatTooOldException | IndexFormatTooNewException ex) {
226230
markStoreCorrupted(ex);
227231
throw ex;
228232
}
229233
}
230234

231235
/**
232-
* Returns the segments info for the given commit or for the latest commit if the given commit is <code>null</code>
236+
* Returns the segments info for the given commit or for the latest commit if the given commit is <code>null</code>.
237+
* This method will throw an exception if the index is older than the standard backwards compatibility
238+
* policy ( current major - 1). See also {@link #readSegmentInfosExtendedCompatibility(Directory, org.opensearch.Version)}.
233239
*
234240
* @throws IOException if the index is corrupted or the segments file is not present
235241
*/
@@ -245,7 +251,27 @@ private static SegmentInfos readSegmentsInfo(IndexCommit commit, Directory direc
245251
} catch (Exception ex) {
246252
throw new CorruptIndexException("Hit unexpected exception while reading segment infos", "commit(" + commit + ")", ex);
247253
}
254+
}
248255

256+
/**
257+
* Returns the segments info for the latest commit in the given directory. Unlike
258+
* {@link #readSegmentsInfo(IndexCommit, Directory)}, this method supports reading
259+
* older Lucene indices on a best-effort basis.
260+
*
261+
* @throws IOException if the index is corrupted or the segments file is not present
262+
*/
263+
private static SegmentInfos readSegmentInfosExtendedCompatibility(Directory directory, org.opensearch.Version minimumVersion)
264+
throws IOException {
265+
try {
266+
return Lucene.readSegmentInfosExtendedCompatibility(directory, minimumVersion);
267+
} catch (EOFException eof) {
268+
// TODO this should be caught by lucene - EOF is almost certainly an index corruption
269+
throw new CorruptIndexException("Read past EOF while reading segment infos", "<latest-commit>", eof);
270+
} catch (IOException exception) {
271+
throw exception; // IOExceptions like too many open files are not necessarily a corruption - just bubble it up
272+
} catch (Exception ex) {
273+
throw new CorruptIndexException("Hit unexpected exception while reading segment infos", "<latest-commit>", ex);
274+
}
249275
}
250276

251277
final void ensureOpen() {

server/src/main/java/org/opensearch/index/store/remote/directory/RemoteSnapshotDirectory.java

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import org.apache.lucene.store.IndexOutput;
2323
import org.apache.lucene.store.Lock;
2424
import org.apache.lucene.store.NoLockFactory;
25+
import org.opensearch.LegacyESVersion;
26+
import org.opensearch.Version;
2527
import org.opensearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot;
2628
import org.opensearch.index.store.remote.file.OnDemandBlockSnapshotIndexInput;
2729
import org.opensearch.index.store.remote.file.OnDemandVirtualFileSnapshotIndexInput;
@@ -35,6 +37,9 @@
3537
* @opensearch.internal
3638
*/
3739
public final class RemoteSnapshotDirectory extends Directory {
40+
41+
public static final Version SEARCHABLE_SNAPSHOT_EXTENDED_COMPATIBILITY_MINIMUM_VERSION = LegacyESVersion.fromId(6000099);
42+
3843
private static final String VIRTUAL_FILE_PREFIX = BlobStoreRepository.VIRTUAL_DATA_BLOB_PREFIX;
3944

4045
private final Map<String, BlobStoreIndexShardSnapshot.FileInfo> fileInfoMap;

server/src/main/java/org/opensearch/indices/IndicesService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ private EngineFactory getEngineFactory(final IndexSettings idxSettings) {
911911
if (idxSettings.isSegRepEnabled()) {
912912
return new NRTReplicationEngineFactory();
913913
}
914-
if (IndexModule.Type.REMOTE_SNAPSHOT.match(idxSettings)) {
914+
if (idxSettings.isRemoteSnapshot()) {
915915
return config -> new ReadOnlyEngine(config, new SeqNoStats(0, 0, 0), new TranslogStats(), true, Function.identity(), false);
916916
}
917917
return new InternalEngineFactory();

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import org.opensearch.common.unit.TimeValue;
5454
import org.opensearch.common.util.CancellableThreads;
5555
import org.opensearch.common.util.concurrent.AbstractRunnable;
56-
import org.opensearch.index.IndexModule;
5756
import org.opensearch.index.IndexNotFoundException;
5857
import org.opensearch.index.engine.RecoveryEngineException;
5958
import org.opensearch.index.mapper.MapperException;
@@ -245,7 +244,7 @@ private void doRecovery(final long recoveryId, final StartRecoveryRequest preExi
245244
logger.trace("{} preparing shard for peer recovery", recoveryTarget.shardId());
246245
indexShard.prepareForIndexRecovery();
247246
final boolean hasRemoteTranslog = recoveryTarget.state().getPrimary() == false && indexShard.isRemoteTranslogEnabled();
248-
final boolean hasNoTranslog = IndexModule.Type.REMOTE_SNAPSHOT.match(indexShard.indexSettings());
247+
final boolean hasNoTranslog = indexShard.indexSettings().isRemoteSnapshot();
249248
final boolean verifyTranslog = (hasRemoteTranslog || hasNoTranslog) == false;
250249
final long startingSeqNo = indexShard.recoverLocallyAndFetchStartSeqNo(!hasRemoteTranslog);
251250
assert startingSeqNo == UNASSIGNED_SEQ_NO || recoveryTarget.state().getStage() == RecoveryState.Stage.TRANSLOG

0 commit comments

Comments
 (0)