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) {
|
||||
readAllowed();
|
||||
markSearcherAccessed();
|
||||
final Engine engine = getEngine();
|
||||
final Engine.Searcher searcher = engine.acquireSearcher(source, scope);
|
||||
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.
|
||||
*/
|
||||
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();
|
||||
if (location != null) {
|
||||
addRefreshListener(location, (b) -> {
|
||||
|
|
|
@ -3240,6 +3240,12 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
// now loop until we are fast enough... shouldn't take long
|
||||
primary.awaitShardSearchActive(aBoolean -> {});
|
||||
} 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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue