Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: enable store limit v2 in raftstore-v2 #7098

Merged
merged 6 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 {

Check warning on line 439 in server/cluster/cluster.go

View check run for this annotation

Codecov / codecov/patch

server/cluster/cluster.go#L439

Added line #L439 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I manually switch to v1, will it switch to v2 back?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In past,the store config will persist also, so it will not switch v1 again after tikv restarted.

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
Loading