Mark searcher as accessed in acquireSearcher (#41335)
This fixes an issue where every N seconds a slow search request is triggered since the searcher access time is not set unless the shard is idle. This change moves to a more pro-active approach setting the searcher as accessed all the time.
This commit is contained in:
parent
6b4cf8f0bd
commit
11dc9fe249
|
@ -1215,6 +1215,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
|
||||||
|
|
||||||
private Engine.Searcher acquireSearcher(String source, Engine.SearcherScope scope) {
|
private Engine.Searcher acquireSearcher(String source, Engine.SearcherScope scope) {
|
||||||
readAllowed();
|
readAllowed();
|
||||||
|
markSearcherAccessed();
|
||||||
final Engine engine = getEngine();
|
final Engine engine = getEngine();
|
||||||
final Engine.Searcher searcher = engine.acquireSearcher(source, scope);
|
final Engine.Searcher searcher = engine.acquireSearcher(source, scope);
|
||||||
assert ElasticsearchDirectoryReader.unwrap(searcher.getDirectoryReader())
|
assert ElasticsearchDirectoryReader.unwrap(searcher.getDirectoryReader())
|
||||||
|
@ -2990,9 +2991,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
|
||||||
* <code>true</code> if the listener was registered to wait for a refresh.
|
* <code>true</code> if the listener was registered to wait for a refresh.
|
||||||
*/
|
*/
|
||||||
public final void awaitShardSearchActive(Consumer<Boolean> listener) {
|
public final void awaitShardSearchActive(Consumer<Boolean> listener) {
|
||||||
if (isSearchIdle()) {
|
markSearcherAccessed(); // move the shard into non-search idle
|
||||||
markSearcherAccessed(); // move the shard into non-search idle
|
|
||||||
}
|
|
||||||
final Translog.Location location = pendingRefreshLocation.get();
|
final Translog.Location location = pendingRefreshLocation.get();
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
addRefreshListener(location, (b) -> {
|
addRefreshListener(location, (b) -> {
|
||||||
|
|
|
@ -3240,6 +3240,12 @@ public class IndexShardTests extends IndexShardTestCase {
|
||||||
// now loop until we are fast enough... shouldn't take long
|
// now loop until we are fast enough... shouldn't take long
|
||||||
primary.awaitShardSearchActive(aBoolean -> {});
|
primary.awaitShardSearchActive(aBoolean -> {});
|
||||||
} while (primary.isSearchIdle());
|
} while (primary.isSearchIdle());
|
||||||
|
|
||||||
|
assertBusy(() -> assertTrue(primary.isSearchIdle()));
|
||||||
|
do {
|
||||||
|
// now loop until we are fast enough... shouldn't take long
|
||||||
|
primary.acquireSearcher("test").close();
|
||||||
|
} while (primary.isSearchIdle());
|
||||||
closeShards(primary);
|
closeShards(primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue