Skip to content

Commit

Permalink
Step-align end split from ingester query window
Browse files Browse the repository at this point in the history
Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
  • Loading branch information
Danny Kopping committed Jan 11, 2024
1 parent b7dfa09 commit 75ee015
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 1 addition & 3 deletions pkg/querier/queryrange/split_by_interval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,6 @@ func Test_splitQuery(t *testing.T) {

splits, err := intervals.splitter.split(refTime, []string{tenantID}, req, intervals.splitInterval)
require.NoError(t, err)
//require.Equal(t, want, splits)

if !assert.Equal(t, want, splits) {
t.Logf("expected and actual do not match\n")
defer t.Fail()
Expand Down Expand Up @@ -867,7 +865,7 @@ func Test_splitMetricQuery(t *testing.T) {
},
&LokiRequest{
StartTs: time.Date(2023, 1, 15, 5, 0, 0, 0, time.UTC),
EndTs: time.Date(2023, 1, 15, 5, 5, 30, 0, time.UTC),
EndTs: time.Date(2023, 1, 15, 5, 5, 15, 0, time.UTC),
Step: 15 * seconds,
Query: shortRange,
},
Expand Down
7 changes: 6 additions & 1 deletion pkg/querier/queryrange/splitters.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,12 @@ func (s *metricQuerySplitter) split(execTime time.Time, tenantIDs []string, r qu
s.buildMetricSplits(lokiReq.GetStep(), ingesterQueryInterval, start, end, factory)

// rebound after ingester queries have been split out
end = start
//
// the end time should now be the boundary of the `query_ingester_within` window, which is "start" currently;
// but since start is already step-aligned we need to subtract 1ns to align it down by 1 more step so that we
// get a consistent step between splits
end, _ = s.alignStartEnd(r.GetStep(), start.Add(-time.Nanosecond), end)
// we restore the previous start time (the start time of the query)
start = origStart

// query only overlaps ingester query window, nothing more to do
Expand Down

0 comments on commit 75ee015

Please sign in to comment.