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

Skip backing indices with a disjoint range on @timestamp field. #85162

Merged
merged 31 commits into from
Jul 4, 2022

Conversation

martijnvg
Copy link
Member

Implicitly skip backing indices with a time series range that doesn't match with
a required filter on @timestamp field.

Relates to #74660

Implicitly skip backing indices with a time series range that doesn't match with
a required filter on @timestamp field.

Relates to elastic#74660
@martijnvg martijnvg requested a review from nik9000 March 23, 2022 11:00
@martijnvg
Copy link
Member Author

(this needs more tests)

}

boolean hasTimestampData() {
return indexLongFieldRange.isComplete() && indexLongFieldRange != IndexLongFieldRange.EMPTY;
return timeSeriesRange != null || (indexLongFieldRange.isComplete() && indexLongFieldRange != IndexLongFieldRange.EMPTY);
Copy link
Member

Choose a reason for hiding this comment

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

If it can be null maybe we need to check that in getMaxTimestamp?

Copy link
Member

Choose a reason for hiding this comment

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

And call it @Nullable?

Copy link
Member

Choose a reason for hiding this comment

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

Ah! It can only be null if the range is complete. Safe enough.

Copy link
Member

Choose a reason for hiding this comment

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

Err - why don't we just pass one of the two things in? Like, have indexLongFieldRange make a timeSeriesRange if it is complete?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 Makes sense. I will do that and make this PR production ready.

@martijnvg martijnvg marked this pull request as ready for review May 10, 2022 12:59
@martijnvg martijnvg added >non-issue :Data Management/Data streams Data streams and their lifecycles :StorageEngine/TSDB You know, for Metrics labels May 10, 2022
@martijnvg martijnvg requested a review from nik9000 May 10, 2022 12:59
@elasticmachine elasticmachine added Team:Data Management Meta label for data/management team Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) labels May 10, 2022
@elasticmachine
Copy link
Collaborator

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

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

*/
@Nullable
public TimeSeriesRange getTimeSeriesTimestampRange() {
if (IndexSettings.MODE.get(settings) == IndexMode.TIME_SERIES) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it'd make sense to name this method getConfiguredTimestampRange.

Also, I'd prefer a method on IndexMode for this rather than a hard check. I'm trying to keep the number of == checks on IndexMode to a minimum so you can look at the implementation of IndexMode and see all of the kinds of changes in behavior that it can make to indices.

@martijnvg martijnvg added the :Search/Search Search-related issues that do not fall into other categories label Jun 27, 2022
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Jun 27, 2022
@elasticmachine
Copy link
Collaborator

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

@martijnvg
Copy link
Member Author

run elasticsearch-ci/part-1

public IndexLongFieldRange getConfiguredTimestampRange(IndexMetadata indexMetadata) {
long min = indexMetadata.getTimeSeriesStart().toEpochMilli();
long max = indexMetadata.getTimeSeriesEnd().toEpochMilli();
return IndexLongFieldRange.NO_SHARDS.extendWithShardRange(0, 1, ShardLongFieldRange.of(min, max));
Copy link
Member

Choose a reason for hiding this comment

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

Hey. So. Like. I think I made getTimestampBound and it does like nearly the same thing, right? I feel like that method should be involved in this PR somehow. Or maybe IndexSettings.timestampBounds should be.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I think I can reuse getTimestampBound(...) and then IndexMetadata#getTimeSeriesTimestampRange(...) use that to build a IndexLongFieldRange instance.

Copy link
Member Author

Choose a reason for hiding this comment

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

TimestampBounds needs IndexScopedSettings which I don't have in the context In want to use it.
This technically only needed for dynamically updating endTime field, which is my case isn't needed.
But maybe with a minor change to TimestampBounds, I can use it too.

Copy link
Member

Choose a reason for hiding this comment

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

Ah! Would you be ok to merge this as is and then do some kind of refactoring to make combine the two paths somehow?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I can do that.

@martijnvg
Copy link
Member Author

@elasticmachine update branch

@martijnvg martijnvg added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Jul 4, 2022
@elasticsearchmachine elasticsearchmachine merged commit 577d3e2 into elastic:master Jul 4, 2022
@martijnvg martijnvg deleted the skip_backing_indices branch July 4, 2022 09:39
martijnvg added a commit to martijnvg/elasticsearch that referenced this pull request Jul 4, 2022
…tTimestampBound(...)

`IndexMode#getConfiguredTimestampRange(...)` functionally overlaps a lot with `IndexMode#getTimestampBound(...)`.
In order to reuse `IndexMode#getTimestampBound(...)` for the use case `IndexMode#getConfiguredTimestampRange(...)`
is reused a change had to be made to TimestampBounds.

During query rewrite and in `TimestampFieldMapperService` no `IndexScopedSettings` is available,
so made this an optional parameter. Only the usage in `IndexSettings` needs this, so that the
instance is updated in the case `index.time_series.end_time` setting is updated. In the case of
query rewrite and in `TimestampFieldMapperService` this isn't needed,  since the instance is
kept around and reused.

Followup from elastic#85162
elasticsearchmachine pushed a commit that referenced this pull request Jul 6, 2022
…tTimestampBound(...) (#88258)

`IndexMode#getConfiguredTimestampRange(...)` functionally overlaps a lot
with `IndexMode#getTimestampBound(...)`. In order to reuse
`IndexMode#getTimestampBound(...)` for the use case
`IndexMode#getConfiguredTimestampRange(...)` is reused a change had to
be made to TimestampBounds.

During query rewrite and in `TimestampFieldMapperService` no
`IndexScopedSettings` is available, so made this an optional parameter.
Only the usage in `IndexSettings` needs this, so that the instance is
updated in the case `index.time_series.end_time` setting is updated. In
the case of query rewrite and in `TimestampFieldMapperService` this
isn't needed,  since the instance is kept around and reused.

Followup from #85162
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Data Management/Data streams Data streams and their lifecycles >non-issue :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:Data Management Meta label for data/management team Team:Search Meta label for search team v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants