diff --git a/ttl/ttlworker/job_manager.go b/ttl/ttlworker/job_manager.go index e481a43484ca2..0b427e64318ac 100644 --- a/ttl/ttlworker/job_manager.go +++ b/ttl/ttlworker/job_manager.go @@ -58,7 +58,7 @@ const taskGCTemplate = `DELETE task FROM ON task.job_id = job.current_job_id WHERE job.table_id IS NULL` -const ttlJobHistoryGCTemplate = `DELETE FROM mysql.tidb_ttl_job_history WHERE create_time < CURDATE() - INTERVAL 30 DAY` +const ttlJobHistoryGCTemplate = `DELETE FROM mysql.tidb_ttl_job_history WHERE create_time < CURDATE() - INTERVAL 90 DAY` const timeFormat = "2006-01-02 15:04:05" diff --git a/ttl/ttlworker/job_manager_integration_test.go b/ttl/ttlworker/job_manager_integration_test.go index 6342e153c08ea..5784c7db7c046 100644 --- a/ttl/ttlworker/job_manager_integration_test.go +++ b/ttl/ttlworker/job_manager_integration_test.go @@ -558,11 +558,13 @@ func TestGCTTLHistory(t *testing.T) { } addHistory(1, 1) - addHistory(2, 29) - addHistory(3, 30) - addHistory(4, 31) - addHistory(5, 32) + addHistory(2, 30) + addHistory(3, 60) + addHistory(4, 89) + addHistory(5, 90) + addHistory(6, 91) + addHistory(7, 100) se := session.NewSession(tk.Session(), tk.Session(), func(_ session.Session) {}) ttlworker.DoGC(context.TODO(), se) - tk.MustQuery("select job_id from mysql.tidb_ttl_job_history order by job_id asc").Check(testkit.Rows("1", "2", "3")) + tk.MustQuery("select job_id from mysql.tidb_ttl_job_history order by job_id asc").Check(testkit.Rows("1", "2", "3", "4", "5")) }