Skip to content

Commit

Permalink
config: enable store limit v2 in raftstore-v2 (#7098)
Browse files Browse the repository at this point in the history
close #7099

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
bufferflies and ti-chi-bot[bot] committed Sep 18, 2023
1 parent 54eb4e4 commit 559ea7f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func (c *RaftCluster) runStoreConfigSync() {
for {
synced, switchRaftV2Config = c.syncStoreConfig(stores)
if switchRaftV2Config {
if err := c.opt.Persist(c.GetStorage()); err != nil {
if err := c.opt.SwitchRaftV2(c.GetStorage()); err != nil {
log.Warn("store config persisted failed", zap.Error(err))
}
}
Expand Down
4 changes: 4 additions & 0 deletions server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,10 @@ func TestStoreConfigSync(t *testing.T) {
err = opt.Reload(tc.GetStorage())
re.NoError(err)
re.Equal(tc.GetOpts().(*config.PersistOptions).GetStoreConfig(), opt.GetStoreConfig())

re.Equal("v1", opt.GetScheduleConfig().StoreLimitVersion)
re.NoError(opt.SwitchRaftV2(tc.GetStorage()))
re.Equal("v2", opt.GetScheduleConfig().StoreLimitVersion)
}

func TestUpdateStorePendingPeerCount(t *testing.T) {
Expand Down
6 changes: 6 additions & 0 deletions server/config/persist_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,12 @@ type persistedConfig struct {
StoreConfig sc.StoreConfig `json:"store"`
}

// SwitchRaftV2 update some config if tikv raft engine switch into partition raft v2
func (o *PersistOptions) SwitchRaftV2(storage endpoint.ConfigStorage) error {
o.GetScheduleConfig().StoreLimitVersion = "v2"
return o.Persist(storage)
}

// Persist saves the configuration to the storage.
func (o *PersistOptions) Persist(storage endpoint.ConfigStorage) error {
cfg := &persistedConfig{
Expand Down

0 comments on commit 559ea7f

Please sign in to comment.