Skip to content

Commit

Permalink
add config for snapshot
Browse files Browse the repository at this point in the history
Signed-off-by: bufferflies <1045931706@qq.com>
  • Loading branch information
bufferflies committed Jul 29, 2022
1 parent 14cffea commit e3da3cd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ const (
defaultLogFormat = "text"

defaultMaxMovableHotPeerSize = int64(512)

defaultSendSnapshotSize = int64(1000)
)

// Special keys for Labels
Expand Down Expand Up @@ -762,6 +764,8 @@ type ScheduleConfig struct {
// MaxMovableHotPeerSize is the threshold of region size for balance hot region and split bucket scheduler.
// Hot region must be split before moved if it's region size is greater than MaxMovableHotPeerSize.
MaxMovableHotPeerSize int64 `toml:"max-movable-hot-peer-size" json:"max-movable-hot-peer-size,omitempty"`

SendSnapshotSize int64 `toml:"send-snapshot-size" json:"send-snapshot-size"`
}

// Clone returns a cloned scheduling configuration.
Expand Down Expand Up @@ -863,6 +867,10 @@ func (c *ScheduleConfig) adjust(meta *configMetaData, reloading bool) error {
if !meta.IsDefined("enable-cross-table-merge") {
c.EnableCrossTableMerge = defaultEnableCrossTableMerge
}

if !meta.IsDefined("send-snapshot-size") {
adjustInt64(&c.SendSnapshotSize, defaultSendSnapshotSize)
}
adjustFloat64(&c.LowSpaceRatio, defaultLowSpaceRatio)
adjustFloat64(&c.HighSpaceRatio, defaultHighSpaceRatio)

Expand Down
9 changes: 9 additions & 0 deletions server/config/persist_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,15 @@ func (o *PersistOptions) IsLocationReplacementEnabled() bool {
return o.GetScheduleConfig().EnableLocationReplacement
}

// GetSendSnapshotSize returns the send snapshot size.
func (o *PersistOptions) GetSendSnapshotSize() int64 {
size := o.GetScheduleConfig().SendSnapshotSize
if size <= 0 {
size = defaultSendSnapshotSize
}
return size
}

// GetMaxMovableHotPeerSize returns the max movable hot peer size.
func (o *PersistOptions) GetMaxMovableHotPeerSize() int64 {
size := o.GetScheduleConfig().MaxMovableHotPeerSize
Expand Down
6 changes: 5 additions & 1 deletion server/schedule/operator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1002,12 +1002,16 @@ func (oc *OperatorController) getOrCreateStoreLimit(storeID uint64, limitType st

func (oc *OperatorController) getOrCreateSnapLimit(storeID uint64, snapType storelimit.SnapType) *storelimit.SlidingWindows {
s := oc.cluster.GetStore(storeID)
cap := oc.cluster.GetOpts().GetSendSnapshotSize()
if s == nil {
log.Error("invalid store ID", zap.Uint64("store-id", storeID))
return nil
}
if s.GetSnapLimit(snapType) == nil {
oc.cluster.GetBasicCluster().ResetSnapLimit(storeID, snapType)
oc.cluster.GetBasicCluster().ResetSnapLimit(storeID, snapType, cap)
}
if limit := s.GetSnapLimit(snapType); cap != limit.GetCapacity() {
limit.Adjust(cap)
}
return s.GetSnapLimit(snapType)
}

0 comments on commit e3da3cd

Please sign in to comment.