Skip to content

bug(aws/recommendations): RateLimiter.Reset race after #269 parallelised GetAllRecommendations #271

Closed

Description

@cristim

Problem

go test -race ./providers/aws/recommendations/... reports concurrent
writes to (*RateLimiter).Reset after PR #269 parallelised the AWS
service-loop:

WARNING: DATA RACE
Write at 0x... by goroutine N:
  recommendations.(*RateLimiter).Reset()
      providers/aws/recommendations/ratelimiter.go:132
  recommendations.(*Client).GetRecommendations()
      providers/aws/recommendations/client.go:83
  recommendations.(*Client).GetRecommendationsForService()
      providers/aws/recommendations/client.go:158
  recommendations.(*Client).GetAllRecommendations.func{1..5}()
      providers/aws/recommendations/client.go:215

Root cause: Client.rateLimiter is a single *RateLimiter instance
held on the Client struct (client.go:28). Both Reset() and the
internal state mutated by Wait / ShouldRetry / GetRetryCount are
shared across the 5 per-service goroutines launched in
GetAllRecommendations. None of those methods take a lock.

Why it's not been visible

  • The project's default go test invocation doesn't pass -race.
  • The pre-commit hook runs go test without -race.
  • All standard tests pass (the race produces interleaved-state behaviour
    that doesn't typically cause assertion failures, just throttling
    imbalance and inflated retry counts in production).

Acceptance criteria

  • go test -race ./providers/aws/recommendations/... passes from
    providers/aws/.
  • Either:
    • (a) Lock the rate-limiter's mutating methods with an internal
      sync.Mutex (preserves the shared-state-across-services design); or
    • (b) Make each per-service goroutine instantiate its own
      RateLimiter (no shared state) — preferred since AWS Cost Explorer
      rate limits are per-API-call, not aggregate, so the shared limiter
      isn't actually doing useful coordination.
  • Add -race to the pre-commit go test invocation (or to a
    CI-only matrix entry) so future regressions are caught.

References

Activity

  1. added
    triaged
    priority/p3
    severity/low
    impact/internal
    type/bug
    on May 4, 2026
  2. cristim commented on May 28, 2026

    @cristim
    MemberAuthor

    Verification: not shipped (race condition still present)

    PR #270 (merge commit e010987, confirmed in origin/feat/multicloud-web-frontend) addressed the Lambda OOM and 60s timeout by adding a shared semaphore in pkg/concurrency capping concurrent API calls. However, the RateLimiter.Reset data race from issue #271 is NOT fixed: providers/aws/recommendations/ratelimiter.go has no sync.Mutex on mutating methods, and Client.rateLimiter is still a single shared instance accessed by the 6 concurrent per-service goroutines in GetAllRecommendations. The acceptance criterion (go test -race ./providers/aws/recommendations/... passes) is likely still failing. Issue remains open.

  3. added a commit that references this issue on Jun 7, 2026
    650221d
  4. added a commit that references this issue on Jun 19, 2026
    0e64bc8
  5. added 2 commits that reference this issue on Jul 10, 2026
    0e16237
    66e65de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/simpact/internalpriority/p3severity/lowtriagedtype/bugurgency/eventually

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions