Skip to content

Commit

Permalink
ttl: const default ttl job interval (pingcap#53512)
Browse files Browse the repository at this point in the history
  • Loading branch information
ystaticy authored May 24, 2024
1 parent 9657f06 commit 8f958de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion pkg/ddl/ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import (
"github.com/pingcap/tidb/pkg/util/dbterror"
)

// DefaultTTLJobInterval is the default value for ttl job interval.
const DefaultTTLJobInterval = "1h"

func onTTLInfoRemove(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, err error) {
tblInfo, err := GetTableInfoAndCancelFaultJob(t, job, job.SchemaID)
if err != nil {
Expand Down Expand Up @@ -201,7 +204,7 @@ func getTTLInfoInOptions(options []*ast.TableOption) (ttlInfo *model.TTLInfo, tt
IntervalExprStr: intervalExpr,
IntervalTimeUnit: int(op.TimeUnitValue.Unit),
Enable: true,
JobInterval: "1h",
JobInterval: DefaultTTLJobInterval,
}
case ast.TableOptionTTLEnable:
ttlEnable = &op.BoolValue
Expand Down
6 changes: 3 additions & 3 deletions pkg/ddl/ttl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func Test_getTTLInfoInOptions(t *testing.T) {
IntervalExprStr: "5",
IntervalTimeUnit: int(ast.TimeUnitYear),
Enable: true,
JobInterval: "1h",
JobInterval: DefaultTTLJobInterval,
},
nil,
nil,
Expand All @@ -79,7 +79,7 @@ func Test_getTTLInfoInOptions(t *testing.T) {
IntervalExprStr: "5",
IntervalTimeUnit: int(ast.TimeUnitYear),
Enable: false,
JobInterval: "1h",
JobInterval: DefaultTTLJobInterval,
},
&falseValue,
nil,
Expand Down Expand Up @@ -107,7 +107,7 @@ func Test_getTTLInfoInOptions(t *testing.T) {
IntervalExprStr: "5",
IntervalTimeUnit: int(ast.TimeUnitYear),
Enable: true,
JobInterval: "1h",
JobInterval: DefaultTTLJobInterval,
},
&trueValue,
nil,
Expand Down

0 comments on commit 8f958de

Please sign in to comment.