Skip to content

Commit

Permalink
Resolve the incorrect scroll_current when delete or close index (#45226)
Browse files Browse the repository at this point in the history
Resolve the incorrect current scroll for deleted or closed index
  • Loading branch information
wuyunfeng authored and jimczi committed Sep 6, 2019
1 parent f2a6c88 commit 7582af2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ public void add(Stats stats) {
suggestCurrent += stats.suggestCurrent;
}

public void addForClosingShard(Stats stats) {
queryCount += stats.queryCount;
queryTimeInMillis += stats.queryTimeInMillis;

fetchCount += stats.fetchCount;
fetchTimeInMillis += stats.fetchTimeInMillis;

scrollCount += stats.scrollCount;
scrollTimeInMillis += stats.scrollTimeInMillis;
// need consider the count of the shard's current scroll
scrollCount += stats.scrollCurrent;

suggestCount += stats.suggestCount;
suggestTimeInMillis += stats.suggestTimeInMillis;
}

public long getQueryCount() {
return queryCount;
}
Expand Down Expand Up @@ -274,6 +290,13 @@ public void addTotals(SearchStats searchStats) {
totalStats.add(searchStats.totalStats);
}

public void addTotalsForClosingShard(SearchStats searchStats) {
if (searchStats == null) {
return;
}
totalStats.addForClosingShard(searchStats.totalStats);
}

public Stats getTotal() {
return this.totalStats;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,8 @@ public synchronized void beforeIndexShardClosed(ShardId shardId, @Nullable Index
if (indexShard != null) {
getStats.addTotals(indexShard.getStats());
indexingStats.addTotals(indexShard.indexingStats());
searchStats.addTotals(indexShard.searchStats());
// if this index was closed or deleted, we should eliminate the effect of the current scroll for this shard
searchStats.addTotalsForClosingShard(indexShard.searchStats());
mergeStats.addTotals(indexShard.mergeStats());
refreshStats.addTotals(indexShard.refreshStats());
flushStats.addTotals(indexShard.flushStats());
Expand Down

0 comments on commit 7582af2

Please sign in to comment.