Don't mark shard as refreshPending on stats fetching (#40458)
Completion and DocStats are pulled from internal readers instead of external since #33835 and #33847 which doesn't require us to refresh after a stats call since refreshes will happen internally anyhow and that will cause updated stats on ongoing indexing.
This commit is contained in:
parent
b78d63d624
commit
dd624c31b0
|
@ -947,9 +947,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
|
|||
|
||||
public DocsStats docStats() {
|
||||
readAllowed();
|
||||
DocsStats docsStats = getEngine().docStats();
|
||||
markSearcherAccessed();
|
||||
return docsStats;
|
||||
return getEngine().docStats();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1028,11 +1026,7 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
|
|||
public CompletionStats completionStats(String... fields) {
|
||||
readAllowed();
|
||||
try {
|
||||
CompletionStats stats = getEngine().completionStats(fields);
|
||||
// we don't wait for a pending refreshes here since it's a stats call instead we mark it as accessed only which will cause
|
||||
// the next scheduled refresh to go through and refresh the stats as well
|
||||
markSearcherAccessed();
|
||||
return stats;
|
||||
return getEngine().completionStats(fields);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
|
|
|
@ -2767,7 +2767,7 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
});
|
||||
long prevAccessTime = shard.getLastSearcherAccess();
|
||||
indexShard.completionStats();
|
||||
assertThat("searcher was not marked as accessed", shard.getLastSearcherAccess(), greaterThan(prevAccessTime));
|
||||
assertThat("searcher was marked as accessed", shard.getLastSearcherAccess(), equalTo(prevAccessTime));
|
||||
} finally {
|
||||
closeShards(indexShard);
|
||||
}
|
||||
|
@ -2797,7 +2797,7 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
});
|
||||
long prevAccessTime = shard.getLastSearcherAccess();
|
||||
final DocsStats docsStats = indexShard.docStats();
|
||||
assertThat("searcher was not marked as accessed", shard.getLastSearcherAccess(), greaterThan(prevAccessTime));
|
||||
assertThat("searcher was marked as accessed", shard.getLastSearcherAccess(), equalTo(prevAccessTime));
|
||||
assertThat(docsStats.getCount(), equalTo(numDocs));
|
||||
try (Engine.Searcher searcher = indexShard.acquireSearcher("test")) {
|
||||
assertTrue(searcher.reader().numDocs() <= docsStats.getCount());
|
||||
|
|
Loading…
Reference in New Issue