Skip to content

Commit dde2649

Browse files
committed
add debug information
Signed-off-by: Yang Keao <[email protected]>
1 parent ae4b286 commit dde2649

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

ddl/db_partition_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2514,19 +2514,22 @@ func TestExchangePartitionTableCompatiable(t *testing.T) {
25142514
}
25152515

25162516
func TestExchangePartitionMultiTable(t *testing.T) {
2517+
logutil.BgLogger().Info("mdl related variable status before bootstrap", zap.Bool("EnableMDL", variable.EnableMDL.Load()), zap.Bool("EnableConcurrentDDL", variable.EnableConcurrentDDL.Load()))
25172518
store := testkit.CreateMockStore(t)
25182519
tk1 := testkit.NewTestKit(t, store)
2520+
logutil.BgLogger().Info("mdl related variable status after bootstrap", zap.Bool("EnableMDL", variable.EnableMDL.Load()), zap.Bool("EnableConcurrentDDL", variable.EnableConcurrentDDL.Load()))
25192521

25202522
dbName := "ExchangeMultiTable"
25212523
tk1.MustExec(`create schema ` + dbName)
25222524
tk1.MustExec(`use ` + dbName)
2523-
tk1.MustExec(`set @@global.tidb_enable_metadata_lock = 1`)
2525+
tk1.MustExec(`set global tidb_enable_metadata_lock = 'ON'`)
25242526
tk1.MustExec(`CREATE TABLE t1 (a int)`)
25252527
tk1.MustExec(`CREATE TABLE t2 (a int)`)
25262528
tk1.MustExec(`CREATE TABLE tp (a int) partition by hash(a) partitions 3`)
25272529
tk1.MustExec(`insert into t1 values (0)`)
25282530
tk1.MustExec(`insert into t2 values (3)`)
25292531
tk1.MustExec(`insert into tp values (6)`)
2532+
logutil.BgLogger().Info("mdl related variable status after inserting rows", zap.Bool("EnableMDL", variable.EnableMDL.Load()), zap.Bool("EnableConcurrentDDL", variable.EnableConcurrentDDL.Load()))
25302533

25312534
tk2 := testkit.NewTestKit(t, store)
25322535
tk2.MustExec(`use ` + dbName)

ddl/ddl.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,7 @@ func (d *ddl) SwitchMDL(enable bool) error {
12291229
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
12301230
defer cancel()
12311231

1232+
logutil.BgLogger().Info("Switch EnableMDL 1", zap.Bool("arg", enable), zap.Bool("value", variable.EnableMDL.Load()))
12321233
// Disable MDL for test.
12331234
if enable && !variable.DefTiDBEnableConcurrentDDL {
12341235
sql := fmt.Sprintf("UPDATE HIGH_PRIORITY %[1]s.%[2]s SET VARIABLE_VALUE = %[4]d WHERE VARIABLE_NAME = '%[3]s'",
@@ -1247,6 +1248,7 @@ func (d *ddl) SwitchMDL(enable bool) error {
12471248
return nil
12481249
}
12491250

1251+
logutil.BgLogger().Info("Switch EnableMDL 2", zap.Bool("arg", enable), zap.Bool("value", variable.EnableMDL.Load()))
12501252
isEnableBefore := variable.EnableMDL.Load()
12511253
if isEnableBefore == enable {
12521254
return nil
@@ -1268,7 +1270,10 @@ func (d *ddl) SwitchMDL(enable bool) error {
12681270
return errors.New("please wait for all jobs done")
12691271
}
12701272

1273+
logutil.BgLogger().Info("Switch EnableMDL 3", zap.Bool("arg", enable), zap.Bool("value", variable.EnableMDL.Load()))
12711274
variable.EnableMDL.Store(enable)
1275+
logutil.BgLogger().Info("Switch EnableMDL 4", zap.Bool("arg", enable), zap.Bool("value", variable.EnableMDL.Load()))
1276+
12721277
err = kv.RunInNewTxn(kv.WithInternalSourceType(context.Background(), kv.InternalTxnDDL), d.store, true, func(ctx context.Context, txn kv.Transaction) error {
12731278
m := meta.NewMeta(txn)
12741279
oldEnable, _, err := m.GetMetadataLock()

sessionctx/variable/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ go_library(
6767
"@org_golang_x_exp//maps",
6868
"@org_golang_x_exp//slices",
6969
"@org_uber_go_atomic//:atomic",
70+
"@org_uber_go_zap//:zap",
7071
],
7172
)
7273

sessionctx/variable/sysvar.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import (
4848
tikvcfg "github.com/tikv/client-go/v2/config"
4949
tikvstore "github.com/tikv/client-go/v2/kv"
5050
atomic2 "go.uber.org/atomic"
51+
"go.uber.org/zap"
5152
)
5253

5354
// All system variables declared here are ordered by their scopes, which follow the order of scopes below:
@@ -1114,7 +1115,9 @@ var defaultSysVars = []*SysVar{
11141115
return BoolToOnOff(EnableConcurrentDDL.Load()), nil
11151116
}},
11161117
{Scope: ScopeGlobal, Name: TiDBEnableMDL, Value: BoolToOnOff(DefTiDBEnableMDL), Type: TypeBool, SetGlobal: func(_ context.Context, vars *SessionVars, val string) error {
1118+
logutil.BgLogger().Info("mdl related variable status in setting status", zap.Bool("EnableMDL", EnableMDL.Load()), zap.Bool("EnableConcurrentDDL", EnableConcurrentDDL.Load()))
11171119
if EnableMDL.Load() != TiDBOptOn(val) {
1120+
logutil.BgLogger().Info("Switch EnableMDL", zap.Bool("val", TiDBOptOn(val)))
11181121
err := SwitchMDL(TiDBOptOn(val))
11191122
if err != nil {
11201123
return err

0 commit comments

Comments
 (0)