Skip to content

Commit

Permalink
update max retries for tier2 request
Browse files Browse the repository at this point in the history
  • Loading branch information
colindickson committed Mar 12, 2024
1 parent 152e2bd commit 28fb8a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
5 changes: 0 additions & 5 deletions app/tier2.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ func (a *Tier2App) IsReady(ctx context.Context) bool {
}

func (a *Tier2App) setReadiness(ready bool) {
if a.isReady.Load() && !ready {
a.logger.Debug("setting app readiness to false")
} else if !a.isReady.Load() && ready {
a.logger.Debug("setting app readiness to true")
}
a.isReady.Store(ready)
}

Expand Down
2 changes: 1 addition & 1 deletion orchestrator/work/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (w *RemoteWorker) Work(ctx context.Context, unit stage.Unit, workRange *blo
var res *Result
retryIdx := 0
startTime := time.Now()
maxRetries := 100 //TODO: make this configurable
maxRetries := 720 //TODO: make this configurable
err := derr.RetryContext(ctx, uint64(maxRetries), func(ctx context.Context) error {
res = w.work(ctx, request, moduleNames, upstream)
err := res.Error
Expand Down
14 changes: 3 additions & 11 deletions service/tier2.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,15 @@ func NewTier2(
func (s *Tier2Service) isOverloaded() bool {
s.connectionCountMutex.RLock()
defer s.connectionCountMutex.RUnlock()
s.logger.Debug("checking if service is overloaded", zap.Int64("current_concurrent_requests", s.currentConcurrentRequests), zap.Int64("max_concurrent_requests", s.runtimeConfig.MaxConcurrentRequests))
return s.runtimeConfig.MaxConcurrentRequests != 0 && s.currentConcurrentRequests >= s.runtimeConfig.MaxConcurrentRequests

isOverloaded := s.runtimeConfig.MaxConcurrentRequests > 0 && s.currentConcurrentRequests >= s.runtimeConfig.MaxConcurrentRequests
return isOverloaded
}

func (s *Tier2Service) incrementConcurrentRequests() {
s.connectionCountMutex.Lock()
defer s.connectionCountMutex.Unlock()

s.logger.Debug("incrementing concurrent requests", zap.Int64("current_concurrent_requests", s.currentConcurrentRequests))

s.currentConcurrentRequests++
s.setOverloaded()
}
Expand All @@ -141,19 +140,12 @@ func (s *Tier2Service) decrementConcurrentRequests() {
s.connectionCountMutex.Lock()
defer s.connectionCountMutex.Unlock()

s.logger.Debug("decrementing concurrent requests", zap.Int64("current_concurrent_requests", s.currentConcurrentRequests))

s.currentConcurrentRequests--
s.setOverloaded()
}

func (s *Tier2Service) setOverloaded() {
overloaded := s.runtimeConfig.MaxConcurrentRequests != 0 && s.currentConcurrentRequests >= s.runtimeConfig.MaxConcurrentRequests

if overloaded {
s.logger.Debug("service is overloaded", zap.Int64("current_concurrent_requests", s.currentConcurrentRequests), zap.Int64("max_concurrent_requests", s.runtimeConfig.MaxConcurrentRequests))
}

s.setReadyFunc(!overloaded)
}

Expand Down

0 comments on commit 28fb8a5

Please sign in to comment.