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

Sort time series indices by time range in GetDataStreams API #107967

Merged
merged 4 commits into from Apr 30, 2024

Conversation

lkts
Copy link
Contributor

@lkts lkts commented Apr 26, 2024

Previously this logic assumed that time series indices are sorted by their time series range. This is problematic because data stream APIs don't actually enforce this invariant. As seen in below issues it is possible to add an index to data stream that will break the sort order either manually or via DSL.

This PR simply sorts indices in needed order before working with them. It seems appropriate given that this API is not performance sensitive.

Closes #102088, #106890.

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@elasticsearchmachine
Copy link
Collaborator

Hi @lkts, I've created a changelog YAML for you.

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.

Looks good! I left one question.

currentMergedRange = new Tuple<>(currentMergedRange.v1(), end);
} else if (currentMergedRange.v2().compareTo(start) < 0) {
mergedRanges.add(currentMergedRange);
currentMergedRange = new Tuple<>(start, end);
} else {
String message = "previous backing index ["
Copy link
Member

Choose a reason for hiding this comment

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

With the indices getting sorted, I think don't we will ever log this warning? Maybe we should remove it and replace this with an assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is a "should never happen" thing.

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.

lgtm

@lkts lkts merged commit d85fa15 into elastic:main Apr 30, 2024
14 checks passed
@lkts lkts deleted the fix/102088 branch April 30, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unneeded warning log emitted for tsdb data stream that have imported backing indices.
3 participants