enable replica-selector-v2 by default (#1229)

* refine replica selector v2 config

Signed-off-by: crazycs520 <crazycs520@gmail.com>

* add comment

Signed-off-by: crazycs520 <crazycs520@gmail.com>

---------

Signed-off-by: crazycs520 <crazycs520@gmail.com>
This commit is contained in:
crazycs 2024-03-15 15:42:30 +08:00 committed by GitHub
parent 5b6625f167
commit 0606e74e8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 22 deletions

View File

@ -93,6 +93,9 @@ type TiKVClient struct {
// MaxConcurrencyRequestLimit is the max concurrency number of request to be sent the tikv
// 0 means auto adjust by feedback.
MaxConcurrencyRequestLimit int64 `toml:"max-concurrency-request-limit" json:"max-concurrency-request-limit"`
// EnableReplicaSelectorV2 indicate whether to use the new replica-selector-v2.
// TODO(crazycs520): remove this config after the new replica-selector-v2 is stable.
EnableReplicaSelectorV2 bool `toml:"enable-replica-selector-v2" json:"enable-replica-selector-v2"`
}
// AsyncCommit is the config for the async commit feature. The switch to enable it is a system variable.
@ -164,6 +167,7 @@ func DefaultTiKVClient() TiKVClient {
ResolveLockLiteThreshold: 16,
MaxConcurrencyRequestLimit: math.MaxInt64,
EnableReplicaSelectorV2: true,
}
}

View File

@ -82,8 +82,6 @@ type Config struct {
RegionsRefreshInterval uint64
// EnablePreload indicates whether to preload region info when initializing the client.
EnablePreload bool
// EnableReplicaSelectorV2 indicates whether to enable ReplicaSelectorV2.
EnableReplicaSelectorV2 bool
}
// DefaultConfig returns the default configuration.
@ -101,7 +99,6 @@ func DefaultConfig() Config {
TxnScope: "",
EnableAsyncCommit: false,
Enable1PC: false,
EnableReplicaSelectorV2: true,
}
}

View File

@ -50,7 +50,7 @@ type ReplicaSelector interface {
func NewReplicaSelector(
regionCache *RegionCache, regionID RegionVerID, req *tikvrpc.Request, opts ...StoreSelectorOption,
) (ReplicaSelector, error) {
if config.GetGlobalConfig().EnableReplicaSelectorV2 {
if config.GetGlobalConfig().TiKVClient.EnableReplicaSelectorV2 {
return newReplicaSelectorV2(regionCache, regionID, req, opts...)
}
return newReplicaSelector(regionCache, regionID, req, opts...)

View File

@ -2604,13 +2604,13 @@ func (s *testReplicaSelectorSuite) changeRegionLeader(storeId uint64) {
func (s *testReplicaSelectorSuite) runCaseAndCompare(ca1 replicaSelectorAccessPathCase) bool {
ca2 := ca1
config.UpdateGlobal(func(conf *config.Config) {
conf.EnableReplicaSelectorV2 = false
conf.TiKVClient.EnableReplicaSelectorV2 = false
})
sender := ca1.run(s)
ca1.checkResult(s, "v1", sender)
config.UpdateGlobal(func(conf *config.Config) {
conf.EnableReplicaSelectorV2 = true
conf.TiKVClient.EnableReplicaSelectorV2 = true
})
sender = ca2.run(s)
if ca2.expect == nil {
@ -2623,7 +2623,7 @@ func (s *testReplicaSelectorSuite) runCaseAndCompare(ca1 replicaSelectorAccessPa
func (s *testReplicaSelectorSuite) runCase(ca replicaSelectorAccessPathCase, v2 bool) bool {
config.UpdateGlobal(func(conf *config.Config) {
conf.EnableReplicaSelectorV2 = v2
conf.TiKVClient.EnableReplicaSelectorV2 = v2
})
sender := ca.run(s)
version := "v1"
@ -2638,7 +2638,7 @@ func (s *testReplicaSelectorSuite) runMultiCaseAndCompare(cas []replicaSelectorA
expects := make([]accessPathResult, 0, len(cas))
valid := true
config.UpdateGlobal(func(conf *config.Config) {
conf.EnableReplicaSelectorV2 = false
conf.TiKVClient.EnableReplicaSelectorV2 = false
})
for _, ca1 := range cas {
sender := ca1.run(s)
@ -2648,7 +2648,7 @@ func (s *testReplicaSelectorSuite) runMultiCaseAndCompare(cas []replicaSelectorA
}
config.UpdateGlobal(func(conf *config.Config) {
conf.EnableReplicaSelectorV2 = true
conf.TiKVClient.EnableReplicaSelectorV2 = true
})
for i, ca2 := range cas {
sender := ca2.run(s)
@ -3227,7 +3227,7 @@ func BenchmarkReplicaSelector(b *testing.B) {
}()
config.UpdateGlobal(func(conf *config.Config) {
conf.EnableReplicaSelectorV2 = true
conf.TiKVClient.EnableReplicaSelectorV2 = true
})
cnt := 0
allErrs := getAllRegionErrors(nil)