Skip to content

Commit

Permalink
[TT-5987] Fix broken sentinel rate limiter (TykTechnologies#4525)
Browse files Browse the repository at this point in the history
  • Loading branch information
furkansenharputlu authored Dec 13, 2022
1 parent 6a32af5 commit e21df34
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gateway/session_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,17 @@ func (l *SessionLimiter) limitSentinel(currentSession *user.SessionState, key st
rateLimiterKey := RateLimitKeyPrefix + rateScope + currentSession.KeyHash()
rateLimiterSentinelKey := RateLimitKeyPrefix + rateScope + currentSession.KeyHash() + ".BLOCKED"

defer func() {
go l.doRollingWindowWrite(key, rateLimiterKey, rateLimiterSentinelKey, currentSession, store, globalConf, apiLimit, dryRun)
}()

// Check sentinel
_, sentinelActive := store.GetRawKey(rateLimiterSentinelKey)
if sentinelActive == nil {
// Sentinel is set, fail
return true
}

go l.doRollingWindowWrite(key, rateLimiterKey, rateLimiterSentinelKey, currentSession, store, globalConf, apiLimit, dryRun)

return false
}

Expand Down

0 comments on commit e21df34

Please sign in to comment.