-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
When configuring the campaign with all sliding window settings set to 1, including SlidingWindowRate = 1 and SlidingWindowDuration = 2 minutes, the system still sends 2 messages within the 2-minute window. This indicates that the sliding window logic in internal/manager/pipe.go is not enforcing the rate limit correctly.
Steps to Reproduce
- Change performence settings to :
Set all settings to 1 andSlidingWindow = true SlidingWindowRate = 1 SlidingWindowDuration = 2m
- Add at least 2 subscribers.
- Run the campaign and observe message dispatch.
Expected Behavior
Only 1 message should be sent per 2-minute window.
Actual Behavior
2 messages are sent within the same 2-minute window.
Relevant Code Section
hasSliding := p.m.cfg.SlidingWindow &&
p.m.cfg.SlidingWindowRate > 0 &&
p.m.cfg.SlidingWindowDuration.Seconds() > 1
...
if hasSliding {
diff := time.Since(p.m.slidingStart)
if diff >= p.m.cfg.SlidingWindowDuration {
p.m.slidingStart = time.Now()
p.m.slidingCount = 0
continue
}
p.m.slidingCount++
if p.m.slidingCount >= p.m.cfg.SlidingWindowRate {
wait := p.m.cfg.SlidingWindowDuration - diff
p.m.log.Printf("messages exceeded (%d) for the window (%v since %s). Sleeping for %s.",
p.m.slidingCount,
p.m.cfg.SlidingWindowDuration,
p.m.slidingStart.Format(time.RFC822Z),
wait.Round(time.Second)*1)
p.m.slidingCount = 0
time.Sleep(wait)
}
}Additional Notes
The issue seems to be with p.m.slidingCount being incremented before checking the limit and/or the continue statements allowing more messages to pass in the same window.
Likely occurs because the first message increments slidingCount and the check happens after the message has already been queued.
Environment
Version: 5.1.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working