Skip to content

Commit

Permalink
Revert "Ensure FrozenEngine always applies engine-level wrapper (#76100
Browse files Browse the repository at this point in the history
…)"

This reverts commit 90c3de8.
  • Loading branch information
ywelsch committed Aug 5, 2021
1 parent 90c3de8 commit 02fbbf3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public class ReadOnlyEngine extends Engine {

protected volatile TranslogStats translogStats;
private final String commitId;
private final Function<DirectoryReader, DirectoryReader> readerWrapperFunction;

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

protected final ElasticsearchDirectoryReader wrapReader(DirectoryReader reader) throws IOException {
protected final ElasticsearchDirectoryReader wrapReader(DirectoryReader reader,
Function<DirectoryReader, DirectoryReader> readerWrapperFunction) throws IOException {
reader = readerWrapperFunction.apply(reader);
return ElasticsearchDirectoryReader.wrap(reader, engineConfig.getShardId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private synchronized ElasticsearchDirectoryReader getOrOpenReader() throws IOExc
listeners.beforeRefresh();
}
final DirectoryReader dirReader = openDirectory(store.directory(), engineConfig.getIndexSettings().isSoftDeleteEnabled());
reader = lastOpenedReader = wrapReader(dirReader);
reader = lastOpenedReader = wrapReader(dirReader, Function.identity());
processReader(reader);
reader.getReaderCacheHelper().addClosedListener(this::onReaderClosed);
for (ReferenceManager.RefreshListener listeners : config().getInternalRefreshListener()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.index.mapper.SeqNoFieldMapper;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.rest.ESRestTestCase;

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

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

0 comments on commit 02fbbf3

Please sign in to comment.