Skip to content

Commit 02fbbf3

Browse files
committed
Revert "Ensure FrozenEngine always applies engine-level wrapper (#76100)"
This reverts commit 90c3de8.
1 parent 90c3de8 commit 02fbbf3

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public class ReadOnlyEngine extends Engine {
7878

7979
protected volatile TranslogStats translogStats;
8080
private final String commitId;
81-
private final Function<DirectoryReader, DirectoryReader> readerWrapperFunction;
8281

8382
/**
8483
* Creates a new ReadOnlyEngine. This ctor can also be used to open a read-only engine on top of an already opened
@@ -120,8 +119,7 @@ public ReadOnlyEngine(EngineConfig config, SeqNoStats seqNoStats, TranslogStats
120119
this.seqNoStats = seqNoStats;
121120
this.indexCommit = Lucene.getIndexCommit(lastCommittedSegmentInfos, directory);
122121
this.lazilyLoadSoftDeletes = lazilyLoadSoftDeletes;
123-
this.readerWrapperFunction = readerWrapperFunction;
124-
reader = wrapReader(open(indexCommit));
122+
reader = wrapReader(open(indexCommit), readerWrapperFunction);
125123
readerManager = new ElasticsearchReaderManager(reader, refreshListener);
126124
assert translogStats != null || obtainLock : "mutiple translogs instances should not be opened at the same time";
127125
this.translogStats = translogStats != null ? translogStats : translogStats(config, lastCommittedSegmentInfos);
@@ -197,7 +195,8 @@ public void verifyEngineBeforeIndexClosing() throws IllegalStateException {
197195
// reopened as an internal engine, which would be the path to fix the issue.
198196
}
199197

200-
protected final ElasticsearchDirectoryReader wrapReader(DirectoryReader reader) throws IOException {
198+
protected final ElasticsearchDirectoryReader wrapReader(DirectoryReader reader,
199+
Function<DirectoryReader, DirectoryReader> readerWrapperFunction) throws IOException {
201200
reader = readerWrapperFunction.apply(reader);
202201
return ElasticsearchDirectoryReader.wrap(reader, engineConfig.getShardId());
203202
}

x-pack/plugin/core/src/main/java/org/elasticsearch/index/engine/frozen/FrozenEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private synchronized ElasticsearchDirectoryReader getOrOpenReader() throws IOExc
161161
listeners.beforeRefresh();
162162
}
163163
final DirectoryReader dirReader = openDirectory(store.directory(), engineConfig.getIndexSettings().isSoftDeleteEnabled());
164-
reader = lastOpenedReader = wrapReader(dirReader);
164+
reader = lastOpenedReader = wrapReader(dirReader, Function.identity());
165165
processReader(reader);
166166
reader.getReaderCacheHelper().addClosedListener(this::onReaderClosed);
167167
for (ReferenceManager.RefreshListener listeners : config().getInternalRefreshListener()) {

x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/AbstractSearchableSnapshotsRestTestCase.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121
import org.elasticsearch.common.xcontent.XContentBuilder;
2222
import org.elasticsearch.common.xcontent.json.JsonXContent;
2323
import org.elasticsearch.common.xcontent.support.XContentMapValues;
24-
import org.elasticsearch.index.mapper.SeqNoFieldMapper;
2524
import org.elasticsearch.index.query.QueryBuilder;
2625
import org.elasticsearch.index.query.QueryBuilders;
2726
import org.elasticsearch.rest.RestStatus;
2827
import org.elasticsearch.search.builder.SearchSourceBuilder;
29-
import org.elasticsearch.search.sort.SortOrder;
3028
import org.elasticsearch.test.rest.ESRestTestCase;
3129

3230
import java.io.IOException;
@@ -471,12 +469,7 @@ protected static Number count(String index) throws IOException {
471469

472470
protected static Map<String, Object> search(String index, QueryBuilder query, Boolean ignoreThrottled) throws IOException {
473471
final Request request = new Request(HttpPost.METHOD_NAME, '/' + index + "/_search");
474-
final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().trackTotalHits(true).query(query);
475-
if (randomBoolean()) {
476-
// ensures we can always access sequence numbers, even on source-only mounted snapshots
477-
searchSourceBuilder.sort(SeqNoFieldMapper.NAME, SortOrder.ASC);
478-
}
479-
request.setJsonEntity(searchSourceBuilder.toString());
472+
request.setJsonEntity(new SearchSourceBuilder().trackTotalHits(true).query(query).toString());
480473
if (ignoreThrottled != null) {
481474
request.addParameter("ignore_throttled", ignoreThrottled.toString());
482475
}

0 commit comments

Comments
 (0)