Skip to content

fix: take the write lock in status.Render - #2290

Merged
TerryHowe merged 1 commit into
oras-project:mainfrom
wleeaf:fix-status-render-spinner-race
Oct 24, 2026
Merged

TerryHowe merged 1 commit into
oras-project:mainfrom
wleeaf:fix-status-render-spinner-race

Conversation

@wleeaf

@wleeaf wleeaf commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

status.Render advances the spinner and adds a point to the speed window, but it only held s.lock.RLock(). manager.render() runs from both the ticker goroutine and Track, so two renders of the same status could run at once and race on status.mark and the speedWindow fields. Render now takes the write lock, like the update* functions that also modify the status.

Test: Test_status_Render_concurrent renders one in-progress status from 8 goroutines. With go test -race, it fails on main (WARNING: DATA RACE in spinner.symbol / speedWindow.Add) and passes with this change. The concurrent-Track reproduction from the issue showed races in 16 of 20 runs before the change and 0 of 20 after. make test and golangci-lint run pass.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2289

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

Render advances the spinner and the speed window, so concurrent renders
from the ticker and from Track raced under the read lock.

Signed-off-by: Wleeaf <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 24, 2026 06:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

@codecov

codecov Bot commented Oct 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.78%. Comparing base (9218890) to head (270e52e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2290   +/-   ##
=======================================
  Coverage   60.78%   60.78%           
=======================================
  Files         140      140           
  Lines        6092     6092           
=======================================
  Hits         3703     3703           
  Misses       2167     2167           
  Partials      222      222           

☔ View full report in Codecov by Harness.
📢 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.

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@TerryHowe
TerryHowe merged commit ecc3e87 into oras-project:main Oct 24, 2026
10 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.

bug: status.Render mutates the status under a read lock (data race between concurrent renders)

3 participants