Skip to content

fix: use Millisecond instead of Nanosecond for retry delay in cacheVersion#127

Open
Nepomuk5665 wants to merge 1 commit into
aws:masterfrom
Nepomuk5665:fix/retry-delay-time-unit
Open

fix: use Millisecond instead of Nanosecond for retry delay in cacheVersion#127
Nepomuk5665 wants to merge 1 commit into
aws:masterfrom
Nepomuk5665:fix/retry-delay-time-unit

Conversation

@Nepomuk5665
Copy link
Copy Markdown

Summary

Fixes a time unit bug in cacheVersion.go where time.Nanosecond was used instead of time.Millisecond for calculating retry delay duration.

The Bug

In secretcache/cacheVersion.go line 58, the retry delay calculation uses the wrong time unit:

// Before (wrong)
delayDuration := time.Nanosecond * time.Duration(delay)

This should use time.Millisecond to be consistent with the identical retry logic in secretcache/cacheItem.go line 162:

// Correct (cacheItem.go:162)
delayDuration := time.Millisecond * time.Duration(delay)

Impact

The retry delay is 1,000,000x shorter than intended. For example, with exceptionRetryDelayBase = 1 (1ms), the actual delay becomes 1 nanosecond instead of 1 millisecond. This effectively eliminates the exponential backoff mechanism, causing:

  • Immediate retries after failures instead of waiting
  • Potential API throttling due to rapid retry attempts
  • Increased load on AWS Secrets Manager service

Fix

Change time.Nanosecond to time.Millisecond in cacheVersion.go to match the correct implementation in cacheItem.go.

@Nepomuk5665 Nepomuk5665 requested a review from a team as a code owner January 23, 2026 11:03
@simonmarty
Copy link
Copy Markdown
Contributor

Thanks for the bug fix. I'm tempted to turn these into Durations directly instead (aside from the growth factor)

exceptionRetryDelayBase = 1
exceptionRetryGrowthFactor = 2
exceptionRetryDelayMax = 3600
forceRefreshJitterSleep = 5000
to clear up this confusion.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.80%. Comparing base (8bf0ef6) to head (2b173d4).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #127   +/-   ##
=======================================
  Coverage   95.80%   95.80%           
=======================================
  Files           7        7           
  Lines         286      286           
=======================================
  Hits          274      274           
  Misses         10       10           
  Partials        2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants