copr: set the default value of load-based replica read threshold to 1s (#43149)
close pingcap/tidb#43148
This commit is contained in:
@ -854,7 +854,9 @@ const (
|
||||
version139 = 139
|
||||
// version 140 add column task_key to mysql.tidb_global_task
|
||||
version140 = 140
|
||||
// version 141 set the value of `tidb_session_plan_cache_size` to "tidb_prepared_plan_cache_size" if there is no `tidb_session_plan_cache_size`.
|
||||
// version 141
|
||||
// set the value of `tidb_session_plan_cache_size` to "tidb_prepared_plan_cache_size" if there is no `tidb_session_plan_cache_size`.
|
||||
// update tidb_load_based_replica_read_threshold from 0 to 4
|
||||
// This will only happens when we upgrade a cluster before 7.1.
|
||||
version141 = 141
|
||||
// version 142 insert "tidb_enable_non_prepared_plan_cache|0" to mysql.GLOBAL_VARIABLES if there is no tidb_enable_non_prepared_plan_cache.
|
||||
@ -2447,7 +2449,8 @@ func upgradeToVer140(s Session, ver int64) {
|
||||
doReentrantDDL(s, "ALTER TABLE mysql.tidb_global_task ADD UNIQUE KEY task_key(task_key)", dbterror.ErrDupKeyName)
|
||||
}
|
||||
|
||||
// upgradeToVer141 sets the value of `tidb_session_plan_cache_size` as `tidb_prepared_plan_cache_size` for compatibility.
|
||||
// upgradeToVer141 sets the value of `tidb_session_plan_cache_size` as `tidb_prepared_plan_cache_size` for compatibility,
|
||||
// and update tidb_load_based_replica_read_threshold from 0 to 4.
|
||||
func upgradeToVer141(s Session, ver int64) {
|
||||
if ver >= version141 {
|
||||
return
|
||||
@ -2469,6 +2472,7 @@ func upgradeToVer141(s Session, ver int64) {
|
||||
|
||||
mustExecute(s, "INSERT HIGH_PRIORITY IGNORE INTO %n.%n VALUES (%?, %?);",
|
||||
mysql.SystemDB, mysql.GlobalVariablesTable, variable.TiDBSessionPlanCacheSize, val)
|
||||
mustExecute(s, "REPLACE HIGH_PRIORITY INTO %n.%n VALUES (%?, %?);", mysql.SystemDB, mysql.GlobalVariablesTable, variable.TiDBLoadBasedReplicaReadThreshold, variable.DefTiDBLoadBasedReplicaReadThreshold.String())
|
||||
}
|
||||
|
||||
func upgradeToVer142(s Session, ver int64) {
|
||||
|
||||
@ -2048,3 +2048,56 @@ func TestTiDBTiDBOptTiDBOptimizerEnableNAAJWhenUpgradingToVer138(t *testing.T) {
|
||||
require.Equal(t, 2, row.Len())
|
||||
require.Equal(t, "ON", row.GetString(1))
|
||||
}
|
||||
|
||||
func TestTiDBLoadBasedReplicaReadThresholdUpgradingToVer141(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
store, _ := CreateStoreAndBootstrap(t)
|
||||
defer func() { require.NoError(t, store.Close()) }()
|
||||
|
||||
// upgrade from 7.0 to 7.1.
|
||||
ver70 := version139
|
||||
seV70 := CreateSessionAndSetID(t, store)
|
||||
txn, err := store.Begin()
|
||||
require.NoError(t, err)
|
||||
m := meta.NewMeta(txn)
|
||||
err = m.FinishBootstrap(int64(ver70))
|
||||
require.NoError(t, err)
|
||||
err = txn.Commit(context.Background())
|
||||
require.NoError(t, err)
|
||||
mustExec(t, seV70, fmt.Sprintf("update mysql.tidb set variable_value=%d where variable_name='tidb_server_version'", ver70))
|
||||
mustExec(t, seV70, fmt.Sprintf("update mysql.GLOBAL_VARIABLES set variable_value='%s' where variable_name='%s'", "0", variable.TiDBLoadBasedReplicaReadThreshold))
|
||||
mustExec(t, seV70, "commit")
|
||||
unsetStoreBootstrapped(store.UUID())
|
||||
ver, err := getBootstrapVersion(seV70)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, int64(ver70), ver)
|
||||
|
||||
// We are now in 7.0, tidb_load_based_replica_read_threshold is 0.
|
||||
res := mustExecToRecodeSet(t, seV70, fmt.Sprintf("select * from mysql.GLOBAL_VARIABLES where variable_name='%s'", variable.TiDBLoadBasedReplicaReadThreshold))
|
||||
chk := res.NewChunk(nil)
|
||||
err = res.Next(ctx, chk)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, chk.NumRows())
|
||||
row := chk.GetRow(0)
|
||||
require.Equal(t, 2, row.Len())
|
||||
require.Equal(t, "0", row.GetString(1))
|
||||
|
||||
// Upgrade to 7.1.
|
||||
domCurVer, err := BootstrapSession(store)
|
||||
require.NoError(t, err)
|
||||
defer domCurVer.Close()
|
||||
seCurVer := CreateSessionAndSetID(t, store)
|
||||
ver, err = getBootstrapVersion(seCurVer)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, currentBootstrapVersion, ver)
|
||||
|
||||
// We are now in 7.1.
|
||||
res = mustExecToRecodeSet(t, seCurVer, fmt.Sprintf("select * from mysql.GLOBAL_VARIABLES where variable_name='%s'", variable.TiDBLoadBasedReplicaReadThreshold))
|
||||
chk = res.NewChunk(nil)
|
||||
err = res.Next(ctx, chk)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, chk.NumRows())
|
||||
row = chk.GetRow(0)
|
||||
require.Equal(t, 2, row.Len())
|
||||
require.Equal(t, "1s", row.GetString(1))
|
||||
}
|
||||
|
||||
@ -2439,7 +2439,7 @@ var defaultSysVars = []*SysVar{
|
||||
s.EnableLateMaterialization = TiDBOptOn(val)
|
||||
return nil
|
||||
}},
|
||||
{Scope: ScopeGlobal | ScopeSession, Name: TiDBLoadBasedReplicaReadThreshold, Value: time.Duration(DefTiDBLoadBasedReplicaReadThreshold).String(), Type: TypeDuration, MaxValue: uint64(time.Hour), SetSession: func(s *SessionVars, val string) error {
|
||||
{Scope: ScopeGlobal | ScopeSession, Name: TiDBLoadBasedReplicaReadThreshold, Value: DefTiDBLoadBasedReplicaReadThreshold.String(), Type: TypeDuration, MaxValue: uint64(time.Hour), SetSession: func(s *SessionVars, val string) error {
|
||||
d, err := time.ParseDuration(val)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -1253,7 +1253,7 @@ const (
|
||||
DefTiDBEnablePlanCacheForParamLimit = true
|
||||
DefTiFlashComputeDispatchPolicy = tiflashcompute.DispatchPolicyConsistentHashStr
|
||||
DefTiDBEnablePlanCacheForSubquery = true
|
||||
DefTiDBLoadBasedReplicaReadThreshold = 0
|
||||
DefTiDBLoadBasedReplicaReadThreshold = time.Second
|
||||
DefTiDBOptEnableLateMaterialization = true
|
||||
DefTiDBOptOrderingIdxSelThresh = 0.0
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user