Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl: add a warning after successfully reorganizing partitions (#42367) #42561

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
6 changes: 5 additions & 1 deletion executor/autoidtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ 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",
<<<<<<< HEAD
shard_count = 5,
=======
shard_count = 11,
>>>>>>> f1df9351785 (ddl: add a warning after successfully reorganizing partitions (#42367))
CbcWestwolf marked this conversation as resolved.
Show resolved Hide resolved
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...)
}
4 changes: 4 additions & 0 deletions executor/simpletest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ go_test(
],
flaky = True,
race = "on",
<<<<<<< HEAD
shard_count = 30,
=======
shard_count = 50,
>>>>>>> f1df9351785 (ddl: add a warning after successfully reorganizing partitions (#42367))
CbcWestwolf marked this conversation as resolved.
Show resolved Hide resolved
deps = [
"//config",
"//domain",
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