Skip to content

Fill the refresh cache before the concurrent requests in the refresh test - #330

Merged
umputun merged 1 commit into
masterfrom
fix-refresh-cache-test-flake
Nov 11, 2026
Merged

umputun merged 1 commit into
masterfrom
fix-refresh-cache-test-flake

Conversation

@umputun

@umputun umputun commented Nov 11, 2026

Copy link
Copy Markdown
Member

TestAuthJWTRefreshConcurrentWithCache fails under -race on a loaded machine, with 2 cache misses and 2 refreshes instead of 1. It sends 100 requests with the same expired token and relied on a 1ms delay between launches to get exactly one refresh. The middleware checks the refresh cache and fills it as separate steps, so a second request can miss the cache before the first one stores its token.

one request now fills the cache first and the other 99 run together with no delay. The assertions stay exact (1 miss, 99 hits, 1 refresh), in both the root and v2 modules. At load 60-70 the old test failed 1 of 50 race runs on master, the new one passed 50 of 50 in each module.

TestAuthJWTRefreshConcurrentWithCache expected one cache miss and one
refresh from 100 requests carrying the same expired token, and relied on
a 1ms delay between launches for that. The middleware checks the cache
and fills it as separate steps, so on a loaded machine a second request
missed the cache before the first stored its token, and the race run
failed with 2 misses and 2 refreshes. One request now fills the cache
first and the other 99 run together with no delay, in both modules.
Copilot AI balanced review requested due to automatic review settings November 11, 2026 17:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@coveralls

coveralls commented Nov 11, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 43066481322

Coverage decreased (-0.02%) to 87.046%

Details

  • Coverage decreased (-0.02%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 3914
Covered Lines: 3407
Line Coverage: 87.05%
Coverage Strength: 10.5 hits per line

💛 - Coveralls

@umputun
umputun merged commit b082b10 into master Nov 11, 2026
8 of 9 checks passed
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.

3 participants