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

query-frontend: inclusive results when start/end are the same #3527

Merged
merged 1 commit into from Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -19,7 +19,7 @@ We use _breaking :warning:_ to mark changes that are not backward compatible (re

### Fixed

-
- [#3527](https://github.com/thanos-io/thanos/pull/3527) Query Frontend: Fix query_range behavior when start/end times are the same

### Changed

Expand Down
16 changes: 10 additions & 6 deletions pkg/queryfrontend/split_by_interval.go
Expand Up @@ -68,13 +68,17 @@ func (s splitByInterval) Do(ctx context.Context, r queryrange.Request) (queryran
func splitQuery(r queryrange.Request, interval time.Duration) []queryrange.Request {
var reqs []queryrange.Request
if _, ok := r.(*ThanosQueryRangeRequest); ok {
for start := r.GetStart(); start < r.GetEnd(); start = nextIntervalBoundary(start, r.GetStep(), interval) + r.GetStep() {
end := nextIntervalBoundary(start, r.GetStep(), interval)
if end+r.GetStep() >= r.GetEnd() {
end = r.GetEnd()
if start := r.GetStart(); start == r.GetEnd() {
reqs = append(reqs, r.WithStartEnd(start, start))
} else {
for ; start < r.GetEnd(); start = nextIntervalBoundary(start, r.GetStep(), interval) + r.GetStep() {
end := nextIntervalBoundary(start, r.GetStep(), interval)
if end+r.GetStep() >= r.GetEnd() {
end = r.GetEnd()
}

reqs = append(reqs, r.WithStartEnd(start, end))
}

reqs = append(reqs, r.WithStartEnd(start, end))
}
} else {
dur := int64(interval / time.Millisecond)
Expand Down