Skip to content

Commit c9e8d20

Browse files
committed
update
Signed-off-by: Weizhen Wang <[email protected]>
1 parent f71c47f commit c9e8d20

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

pkg/executor/historical_stats_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,10 @@ func TestAssertHistoricalStatsAfterAlterTable(t *testing.T) {
238238
}
239239

240240
func TestGCOutdatedHistoryStats(t *testing.T) {
241-
failpoint.Enable("github.com/pingcap/tidb/pkg/domain/sendHistoricalStats", "return(true)")
242-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/domain/sendHistoricalStats")
241+
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/domain/sendHistoricalStats", "return(true)"))
242+
defer func() {
243+
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/pkg/domain/sendHistoricalStats"))
244+
}()
243245
store, dom := testkit.CreateMockStoreAndDomain(t)
244246
tk := testkit.NewTestKit(t, store)
245247
tk.MustExec("set global tidb_enable_historical_stats = 1")

pkg/session/session.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,8 +1641,12 @@ func (s *session) ExecuteInternal(ctx context.Context, sql string, args ...inter
16411641
if err != nil {
16421642
return nil, err
16431643
}
1644+
if sq, ok := stmtNode.(*ast.NonTransactionalDMLStmt); ok {
1645+
rs, err = HandleNonTransactionalDML(ctx, sq, s)
1646+
} else {
1647+
rs, err = s.ExecuteStmt(ctx, stmtNode)
1648+
}
16441649

1645-
rs, err = s.ExecuteStmt(ctx, stmtNode)
16461650
if err != nil {
16471651
s.sessionVars.StmtCtx.AppendError(err)
16481652
}

pkg/statistics/handle/storage/gc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,12 @@ func ClearOutdatedHistoryStats(sctx sessionctx.Context) error {
182182
}
183183
count := rows[0].GetInt64(0)
184184
if count > 0 {
185-
sql = "batch on table_id limit 100 delete from mysql.stats_meta_history use index (idx_create_time) where create_time <= NOW() - INTERVAL %? SECOND"
185+
sql = "batch on create_time limit 10 delete from mysql.stats_meta_history use index (idx_create_time) where create_time <= NOW() - INTERVAL %? SECOND"
186186
_, err = util.Exec(sctx, sql, variable.HistoricalStatsDuration.Load().Seconds())
187187
if err != nil {
188188
return err
189189
}
190-
sql = "batch on table_id limit 100 delete from mysql.stats_history use index (idx_create_time) where create_time <= NOW() - INTERVAL %? SECOND"
190+
sql = "batch on create_time limit 10 delete from mysql.stats_history use index (idx_create_time) where create_time <= NOW() - INTERVAL %? SECOND"
191191
_, err = util.Exec(sctx, sql, variable.HistoricalStatsDuration.Load().Seconds())
192192
logutil.BgLogger().Info("clear outdated historical stats")
193193
return err

0 commit comments

Comments
 (0)