Skip to content

Fix race condition causing flaky PeriodicMetricReaderTest#8317

Merged
jack-berg merged 1 commit intoopen-telemetry:mainfrom
jack-berg:fix-flaky-test
Apr 23, 2026
Merged

Fix race condition causing flaky PeriodicMetricReaderTest#8317
jack-berg merged 1 commit intoopen-telemetry:mainfrom
jack-berg:fix-flaky-test

Conversation

@jack-berg
Copy link
Copy Markdown
Member

Fixes #8306

Race:

  1. forceFlush() calls doRun(), which sets exportAvailable = false and assigns flushInProgress = flushResult
  2. shutdown() calls flushInProgress.join() — waiting for the in-flight export
  3. The blocking export completes → whenComplete fires: flushResult.succeed() (line 226) → shutdown() unblocks
  4. Race: exportAvailable.set(true) (line 227) hasn't run yet
  5. shutdown() calls the final doRun() → CAS exportAvailable true→false fails (still false), so the export is dropped

cc @trask

@jack-berg jack-berg requested a review from a team as a code owner April 22, 2026 18:53
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.28%. Comparing base (5f5b054) to head (5c3619c).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8317      +/-   ##
============================================
+ Coverage     90.25%   90.28%   +0.02%     
- Complexity     7691     7693       +2     
============================================
  Files           850      850              
  Lines         23203    23207       +4     
  Branches       2356     2356              
============================================
+ Hits          20943    20952       +9     
+ Misses         1532     1530       -2     
+ Partials        728      725       -3     

☔ 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.

@jack-berg jack-berg merged commit bc542ae into open-telemetry:main Apr 23, 2026
45 of 47 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.

Test flake from #8299

2 participants