Skip to content

Commit

Permalink
Merge pull request #529 from ahfa92/main
Browse files Browse the repository at this point in the history
fix delaystat overflow when changing retain limit
  • Loading branch information
svaroqui committed Jan 3, 2024
2 parents 7503e94 + 73e4ee9 commit 86f3c1e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cluster/cluster_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func (sds *ServerDelayStat) UpdateDelayWithRotate(s int64, limit int) {
sds.Rotated = sds.DelayHistory[0].DelayStat

//Rotate Stat if exceed limit
if len(sds.DelayHistory) == limit {
sds.DelayHistory = sds.DelayHistory[1:]
if len(sds.DelayHistory) >= limit {
sds.DelayHistory = sds.DelayHistory[(len(sds.DelayHistory)-limit)+1:]
}

sds.ResetCurrentStat() //Reset Current Stat
Expand Down Expand Up @@ -117,8 +117,8 @@ func (sds *ServerDelayStat) UpdateSlaveErrorWithRotate(limit int) {
sds.Rotated = sds.DelayHistory[0].DelayStat

//Rotate Stat if reach limit
if len(sds.DelayHistory) == limit {
sds.DelayHistory = sds.DelayHistory[1:]
if len(sds.DelayHistory) >= limit {
sds.DelayHistory = sds.DelayHistory[(len(sds.DelayHistory)-limit)+1:]
}
sds.ResetCurrentStat() //Reset Current Stat

Expand Down

0 comments on commit 86f3c1e

Please sign in to comment.