Skip to content

Commit

Permalink
resource_control: add duration buffer for calibrate time window (#48172
Browse files Browse the repository at this point in the history
…) (#48353)

close #48162
  • Loading branch information
ti-chi-bot authored Nov 8, 2023
1 parent 38a88b3 commit 52c6053
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion executor/calibrate_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@ func (e *calibrateResourceExec) parseCalibrateDuration(ctx context.Context) (sta
}
// check the duration
dur = endTime.Sub(startTime)
if dur > maxDuration {
// add the buffer duration
if dur > maxDuration+time.Minute {
err = errors.Errorf("the duration of calibration is too long, which could lead to inaccurate output. Please make the duration between %s and %s", minDuration.String(), maxDuration.String())
return
}
// We only need to consider the case where the duration is slightly enlarged.
if dur < minDuration {
err = errors.Errorf("the duration of calibration is too short, which could lead to inaccurate output. Please make the duration between %s and %s", minDuration.String(), maxDuration.String())
}
Expand Down
2 changes: 1 addition & 1 deletion executor/calibrate_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ func TestCalibrateResource(t *testing.T) {
types.MakeDatums(datetime("2020-02-12 10:45:00"), "tikv-2", "tikv", 0.281),
}

rs, err = tk.Exec("CALIBRATE RESOURCE START_TIME '2020-02-12 10:35:00' END_TIME '2020-02-12 10:45:00'")
rs, err = tk.Exec("CALIBRATE RESOURCE START_TIME '2020-02-12 10:35:00' END_TIME '2020-02-13 10:35:01'")
require.NoError(t, err)
require.NotNil(t, rs)
err = rs.Next(ctx, rs.NewChunk(nil))
Expand Down

0 comments on commit 52c6053

Please sign in to comment.