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
close #48162
  • Loading branch information
CabinfeverB authored Nov 7, 2023
1 parent 6020ede commit 97a6b95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,12 @@ func (e *Executor) parseCalibrateDuration(ctx context.Context) (startTime time.T
}
// 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
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,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 97a6b95

Please sign in to comment.