Skip to content

Commit 3ba4230

Browse files
committed
Revert "Ensure FrozenEngine always applies engine-level wrapper (#76100)"
This reverts commit 6f31abc.
1 parent ee66de9 commit 3ba4230

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public class ReadOnlyEngine extends Engine {
7676

7777
protected volatile TranslogStats translogStats;
7878
private final String commitId;
79-
private final Function<DirectoryReader, DirectoryReader> readerWrapperFunction;
8079

8180
/**
8281
* Creates a new ReadOnlyEngine. This ctor can also be used to open a read-only engine on top of an already opened
@@ -117,8 +116,7 @@ public ReadOnlyEngine(EngineConfig config, SeqNoStats seqNoStats, TranslogStats
117116
this.seqNoStats = seqNoStats;
118117
this.indexCommit = Lucene.getIndexCommit(lastCommittedSegmentInfos, directory);
119118
this.lazilyLoadSoftDeletes = lazilyLoadSoftDeletes;
120-
this.readerWrapperFunction = readerWrapperFunction;
121-
reader = wrapReader(open(indexCommit));
119+
reader = wrapReader(open(indexCommit), readerWrapperFunction);
122120
readerManager = new ElasticsearchReaderManager(reader);
123121
assert translogStats != null || obtainLock : "mutiple translogs instances should not be opened at the same time";
124122
this.translogStats = translogStats != null ? translogStats : translogStats(config, lastCommittedSegmentInfos);
@@ -194,7 +192,8 @@ public void verifyEngineBeforeIndexClosing() throws IllegalStateException {
194192
// reopened as an internal engine, which would be the path to fix the issue.
195193
}
196194

197-
protected final ElasticsearchDirectoryReader wrapReader(DirectoryReader reader) throws IOException {
195+
protected final ElasticsearchDirectoryReader wrapReader(DirectoryReader reader,
196+
Function<DirectoryReader, DirectoryReader> readerWrapperFunction) throws IOException {
198197
reader = readerWrapperFunction.apply(reader);
199198
return ElasticsearchDirectoryReader.wrap(reader, engineConfig.getShardId());
200199
}

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

+1-1
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(engineConfig.getStore().directory());
164-
reader = lastOpenedReader = wrapReader(dirReader);
164+
reader = lastOpenedReader = wrapReader(dirReader, Function.identity());
165165
reader.getReaderCacheHelper().addClosedListener(this::onReaderClosed);
166166
for (ReferenceManager.RefreshListener listeners : config().getInternalRefreshListener()) {
167167
listeners.afterRefresh(true);

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

+1-8
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;
@@ -470,12 +468,7 @@ protected static Number count(String index) throws IOException {
470468

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

0 commit comments

Comments
 (0)