Skip to content

Commit

Permalink
Don't mark shard as refreshPending on stats fetching (#40458)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
s1monw committed Apr 2, 2019
1 parent 3ecfd9b commit 1f019eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -947,9 +947,7 @@ public FlushStats flushStats() {

public DocsStats docStats() {
readAllowed();
DocsStats docsStats = getEngine().docStats();
markSearcherAccessed();
return docsStats;
return getEngine().docStats();
}

/**
Expand Down Expand Up @@ -1028,11 +1026,7 @@ public TranslogStats translogStats() {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2767,7 +2767,7 @@ public void testCompletionStatsMarksSearcherAccessed() throws Exception {
});
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);
}
Expand Down Expand Up @@ -2797,7 +2797,7 @@ public void testDocStats() throws Exception {
});
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());
Expand Down

0 comments on commit 1f019eb

Please sign in to comment.