Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include search idle info to shard stats #95740

Conversation

salvatore-campagna
Copy link
Contributor

@salvatore-campagna salvatore-campagna commented May 2, 2023

Extend the Index Stats API to include information about shard idleness.
To be more precise we include two pieces of info:

  • a boolean indicating if a shard is idle at the moment the API call takes place
  • a long value indicating the time in milliseconds the shard has been search idle since the last time it went into search idle state

Resolves #95727

@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label v8.9.0 labels May 2, 2023
@salvatore-campagna salvatore-campagna self-assigned this May 2, 2023
@salvatore-campagna salvatore-campagna added :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team :StorageEngine/TSDB You know, for Metrics Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) >enhancement and removed needs:triage Requires assignment of a team area label labels May 2, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@elasticsearchmachine
Copy link
Collaborator

Hi @salvatore-campagna, I've created a changelog YAML for you.

@elasticsearchmachine
Copy link
Collaborator

Hi @salvatore-campagna, I've updated the changelog YAML for you.

@salvatore-campagna salvatore-campagna added the test-full-bwc Trigger full BWC version matrix tests label May 2, 2023
@salvatore-campagna
Copy link
Contributor Author

@elasticsearchmachine test this please

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I left a comment about where to place these new stats and testing.

@@ -182,4 +200,27 @@ private void ensureNoPendingScheduledRefresh(ThreadPool threadPool) {
barrier.arriveAndAwaitAdvance();
}

public void testSearchIdleStats() throws InterruptedException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add a yaml test to rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.stats dir?
Just to verify that the new fields are included in the stats response

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about that even if the stats api sued at shard level returns a lot of data that I can't actually check with match. Also for search idle I can't check the values in the test...just that the fields exist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.just that the fields exist.

and that is what I think we should test for. We can't assert what actual values are there, just the existence of the new fields.

.prepareCreate(indexName)
.setSettings(
Settings.builder()
.put(IndexSettings.INDEX_SEARCH_IDLE_AFTER.getKey(), searchIdleAfter + "s")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe reduce this idle after to something like 100ms here? Otherwise it increases the time to run this test significantly.

@@ -211,6 +259,9 @@ static final class Fields {
static final String PRIMARY = "primary";
static final String NODE = "node";
static final String RELOCATING_NODE = "relocating_node";
static final String SEARCH_IDLE = "search_idle";
static final String IS_SEARCH_IDLE = "is_idle";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really happy with search_idle object. Thinking more about this, maybe we should add these two fields to SearchStats?


import java.util.concurrent.TimeUnit;

public class SearchIdleStatsTests extends ESSingleNodeTestCase {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this either need to have a IT suffix or be moved to server/src/test/java?

@@ -316,6 +338,8 @@ public void add(SearchStats searchStats) {
groupStats.get(entry.getKey()).add(entry.getValue());
}
}
isSearchIdle = searchStats.isSearchIdle;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If shards stats are collected in index or data stream level, this could hide shards that are search idle.
Maybe we should report sum or max idle time? Or maybe we should move this information back to ShardStats?

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one comment, LGTM otherwise.

@@ -211,6 +257,8 @@ static final class Fields {
static final String PRIMARY = "primary";
static final String NODE = "node";
static final String RELOCATING_NODE = "relocating_node";
static final String IS_SEARCH_IDLE = "is_search_idle";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just search_idle instead of is_search_idle? I think boolean fields don't usually get the is_ prefix. (see for example primary field)

@salvatore-campagna salvatore-campagna merged commit f523caf into elastic:main May 16, 2023
mark-vieira added a commit to mark-vieira/elasticsearch that referenced this pull request May 17, 2023
elasticsearchmachine pushed a commit that referenced this pull request May 17, 2023
This reverts commit f523caf.

#95740 introduced a transport protocol change but using the old stack
version transport versions. This breaks inter-commit backward
compatibility. This pull request reverts this for now until we can go
back and reintroduce the change using a new transport version.
@mark-vieira
Copy link
Contributor

This PR got merged after the update to transport versions and mistakenly introduced a usage of an existing transport version. In this case the 8_9_0. We should have introduced a new transport version here. I've reverted this commit for now in #96204 since it breaks backwards compatibility.

salvatore-campagna added a commit to salvatore-campagna/elasticsearch that referenced this pull request May 18, 2023
Extend the Index Stats API to include information about shard idleness.
To be more precise we include two pieces of info:
* a boolean indicating if a shard is idle at the moment the API call takes place
* a long value indicating the time in milliseconds the shard has been search idle
  since the last time it went into search idle state
salvatore-campagna added a commit that referenced this pull request May 19, 2023
Include search idle info to shard stats (#95740)

Extend the Index Stats API to include information about shard idleness.
To be more precise we include two pieces of info:
* a boolean indicating if a shard is idle at the moment the API call takes place
* a long value indicating the time in milliseconds the shard has been search idle
  since the last time it went into search idle state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories :StorageEngine/TSDB You know, for Metrics Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:Search Meta label for search team test-full-bwc Trigger full BWC version matrix tests v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Indices stats search idle time
4 participants