Skip to content

Commit

Permalink
ddl: add a warning after successfully reorganizing partitions (#42367)
Browse files Browse the repository at this point in the history
close #42183
  • Loading branch information
CbcWestwolf authored Mar 24, 2023
1 parent 58d8de2 commit f1df935
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
12 changes: 12 additions & 0 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4396,3 +4396,15 @@ func TestDisableDDL(t *testing.T) {
tk.MustGetErrCode("set @@global.tidb_enable_ddl=false;", errno.ErrDDLSetting)
tk.MustQuery("select @@global.tidb_enable_ddl").Check(testkit.Rows("1"))
}

func TestReorganizePartitionWarning(t *testing.T) {
// https://github.com/pingcap/tidb/issues/42183
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")

tk.MustExec("drop table if exists t")
tk.MustExec("create table t (id bigint, b varchar(20), index idxb(b)) partition by range(id) (partition p0 values less than (20), partition p1 values less than (100));")
tk.MustExec("alter table t reorganize partition p0 into (partition p01 values less than (10), partition p02 values less than (20));")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 The statistics of related partitions will be outdated after reorganizing partitions. Please use 'ANALYZE TABLE' statement if you want to update it now"))
}
3 changes: 3 additions & 0 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4049,6 +4049,9 @@ func (d *ddl) ReorganizePartitions(ctx sessionctx.Context, ident ast.Ident, spec
// No preSplitAndScatter here, it will be done by the worker in onReorganizePartition instead.
err = d.DoDDLJob(ctx, job)
err = d.callHookOnChanged(job, err)
if err == nil {
ctx.GetSessionVars().StmtCtx.AppendWarning(errors.New("The statistics of related partitions will be outdated after reorganizing partitions. Please use 'ANALYZE TABLE' statement if you want to update it now"))
}
return errors.Trace(err)
}

Expand Down
4 changes: 2 additions & 2 deletions executor/autoidtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "autoidtest_test",
timeout = "short",
timeout = "moderate",
srcs = [
"autoid_test.go",
"main_test.go",
],
flaky = True,
race = "on",
shard_count = 10,
shard_count = 11,
deps = [
"//autoid_service",
"//config",
Expand Down
1 change: 1 addition & 0 deletions executor/autoidtest/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func TestMain(m *testing.M) {
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),
goleak.IgnoreTopFunction("gopkg.in/natefinch/lumberjack%2ev2.(*Logger).millRun"),
goleak.IgnoreTopFunction("github.com/tikv/client-go/v2/txnkv/transaction.keepAlive"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
}
goleak.VerifyTestMain(m, opts...)
}
2 changes: 1 addition & 1 deletion executor/simpletest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ go_test(
],
flaky = True,
race = "on",
shard_count = 34,
shard_count = 50,
deps = [
"//config",
"//parser/auth",
Expand Down
2 changes: 1 addition & 1 deletion sessionctx/sessionstates/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ go_test(
],
embed = [":sessionstates"],
flaky = True,
shard_count = 2,
shard_count = 13,
deps = [
"//config",
"//errno",
Expand Down

0 comments on commit f1df935

Please sign in to comment.