diff --git a/session/bootstrap.go b/session/bootstrap.go index 50fae971872d3..5afcba11ae4a2 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -583,13 +583,11 @@ const ( version84 = 84 // version85 updates bindings with status 'using' in mysql.bind_info table to 'enabled' status version85 = 85 - // version86 changes global variable `tidb_enable_top_sql` value from false to true. - version86 = 86 ) // currentBootstrapVersion is defined as a variable, so we can modify its value for testing. // please make sure this is the largest version -var currentBootstrapVersion int64 = version86 +var currentBootstrapVersion int64 = version85 var ( bootstrapVersion = []func(Session, int64){ @@ -678,7 +676,6 @@ var ( upgradeToVer83, upgradeToVer84, upgradeToVer85, - upgradeToVer86, } ) @@ -1755,14 +1752,6 @@ func upgradeToVer85(s Session, ver int64) { mustExecute(s, fmt.Sprintf("UPDATE HIGH_PRIORITY mysql.bind_info SET status= '%s' WHERE status = '%s'", bindinfo.Enabled, bindinfo.Using)) } -func upgradeToVer86(s Session, ver int64) { - if ver >= version86 { - return - } - // Enable Top SQL by default after upgrade - mustExecute(s, "set @@global.tidb_enable_top_sql = 1") -} - func writeOOMAction(s Session) { comment := "oom-action is `log` by default in v3.0.x, `cancel` by default in v4.0.11+" mustExecute(s, `INSERT HIGH_PRIORITY INTO %n.%n VALUES (%?, %?, %?) ON DUPLICATE KEY UPDATE VARIABLE_VALUE= %?`, @@ -1915,10 +1904,6 @@ func doDMLWorks(s Session) { } value := fmt.Sprintf(`("%s", "%s")`, strings.ToLower(k), vVal) values = append(values, value) - - if v.GlobalConfigName != "" { - domain.GetDomain(s).NotifyGlobalConfigChange(v.GlobalConfigName, variable.OnOffToTrueFalse(vVal)) - } } } sql := fmt.Sprintf("INSERT HIGH_PRIORITY INTO %s.%s VALUES %s;", mysql.SystemDB, mysql.GlobalVariablesTable, diff --git a/session/bootstrap_test.go b/session/bootstrap_test.go index 659d237a63b71..581068a9f56bd 100644 --- a/session/bootstrap_test.go +++ b/session/bootstrap_test.go @@ -24,7 +24,6 @@ import ( "github.com/pingcap/tidb/bindinfo" "github.com/pingcap/tidb/config" "github.com/pingcap/tidb/domain" - "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/meta" "github.com/pingcap/tidb/parser/auth" "github.com/pingcap/tidb/sessionctx" @@ -1095,55 +1094,3 @@ func TestUpgradeToVer85(t *testing.T) { require.NoError(t, r.Close()) mustExec(t, se, "delete from mysql.bind_info where default_db = 'test'") } - -func TestUpgradeVersion86(t *testing.T) { - ctx := context.Background() - store, dom := createStoreAndBootstrap(t) - defer func() { require.NoError(t, store.Close()) }() - - seV85 := createSessionAndSetID(t, store) - txn, err := store.Begin() - require.NoError(t, err) - m := meta.NewMeta(txn) - err = m.FinishBootstrap(int64(85)) - require.NoError(t, err) - err = txn.Commit(context.Background()) - require.NoError(t, err) - mustExec(t, seV85, "update mysql.tidb set variable_value='85' where variable_name='tidb_server_version'") - mustExec(t, seV85, "set @@global.tidb_enable_top_sql = 0") - mustExec(t, seV85, "commit") - unsetStoreBootstrapped(store.UUID()) - ver, err := getBootstrapVersion(seV85) - require.NoError(t, err) - require.Equal(t, int64(85), ver) - // Top SQL is disabled in old version TiDB by default. - r := mustExec(t, seV85, `SELECT @@global.tidb_enable_top_sql`) - req := r.NewChunk(nil) - require.NoError(t, r.Next(ctx, req)) - require.Equal(t, 1, req.NumRows()) - row := req.GetRow(0) - require.Equal(t, int64(0), row.GetInt64(0)) - dom.Close() - - // after upgrade. - domV86, err := BootstrapSession(store) - require.NoError(t, err) - defer domV86.Close() - seV86 := createSessionAndSetID(t, store) - ver, err = getBootstrapVersion(seV86) - require.NoError(t, err) - require.Equal(t, currentBootstrapVersion, ver) - r = mustExec(t, seV86, `SELECT @@global.tidb_enable_top_sql`) - req = r.NewChunk(nil) - require.NoError(t, r.Next(ctx, req)) - require.Equal(t, 1, req.NumRows()) - row = req.GetRow(0) - require.Equal(t, int64(1), row.GetInt64(0)) - - storeWithePD, ok := store.(kv.StorageWithPD) - require.True(t, ok) - items, err := storeWithePD.GetPDClient().LoadGlobalConfig(ctx, []string{"enable_resource_metering"}) - require.NoError(t, err) - require.Equal(t, 1, len(items)) - require.Equal(t, "true", items[0].Value) -} diff --git a/util/topsql/state/state.go b/util/topsql/state/state.go index 8c76f68059cbf..d86823e303c0f 100644 --- a/util/topsql/state/state.go +++ b/util/topsql/state/state.go @@ -18,7 +18,7 @@ import "go.uber.org/atomic" // Default Top-SQL state values. const ( - DefTiDBTopSQLEnable = true + DefTiDBTopSQLEnable = false DefTiDBTopSQLPrecisionSeconds = 1 DefTiDBTopSQLMaxTimeSeriesCount = 100 DefTiDBTopSQLMaxMetaCount = 5000