Skip to content

Commit 5bf84bf

Browse files
committed
Don't mark shard as refreshPending on stats fetching
Completion and DocStats are pulled from internal readers instead of external since elastic#33835 and elastic#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.
1 parent 4469cf0 commit 5bf84bf

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -947,9 +947,7 @@ public FlushStats flushStats() {
947947

948948
public DocsStats docStats() {
949949
readAllowed();
950-
DocsStats docsStats = getEngine().docStats();
951-
markSearcherAccessed();
952-
return docsStats;
950+
return getEngine().docStats();
953951
}
954952

955953
/**
@@ -1028,11 +1026,7 @@ public TranslogStats translogStats() {
10281026
public CompletionStats completionStats(String... fields) {
10291027
readAllowed();
10301028
try {
1031-
CompletionStats stats = getEngine().completionStats(fields);
1032-
// 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
1033-
// the next scheduled refresh to go through and refresh the stats as well
1034-
markSearcherAccessed();
1035-
return stats;
1029+
return getEngine().completionStats(fields);
10361030
} catch (IOException e) {
10371031
throw new UncheckedIOException(e);
10381032
}

server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,7 +2763,7 @@ public void testCompletionStatsMarksSearcherAccessed() throws Exception {
27632763
});
27642764
long prevAccessTime = shard.getLastSearcherAccess();
27652765
indexShard.completionStats();
2766-
assertThat("searcher was not marked as accessed", shard.getLastSearcherAccess(), greaterThan(prevAccessTime));
2766+
assertThat("searcher was marked as accessed", shard.getLastSearcherAccess(), equalTo(prevAccessTime));
27672767
} finally {
27682768
closeShards(indexShard);
27692769
}
@@ -2793,7 +2793,7 @@ public void testDocStats() throws Exception {
27932793
});
27942794
long prevAccessTime = shard.getLastSearcherAccess();
27952795
final DocsStats docsStats = indexShard.docStats();
2796-
assertThat("searcher was not marked as accessed", shard.getLastSearcherAccess(), greaterThan(prevAccessTime));
2796+
assertThat("searcher was marked as accessed", shard.getLastSearcherAccess(), equalTo(prevAccessTime));
27972797
assertThat(docsStats.getCount(), equalTo(numDocs));
27982798
try (Engine.Searcher searcher = indexShard.acquireSearcher("test")) {
27992799
assertTrue(searcher.reader().numDocs() <= docsStats.getCount());

0 commit comments

Comments
 (0)