-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix - Uses fetch_add()
to accumulate usage counters in LoadedPrograms
#34319
Fix - Uses fetch_add()
to accumulate usage counters in LoadedPrograms
#34319
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #34319 +/- ##
=======================================
Coverage 81.9% 81.9%
=======================================
Files 819 819
Lines 220228 220225 -3
=======================================
+ Hits 180535 180559 +24
+ Misses 39693 39666 -27 |
Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis. |
Problem
The pattern
load()
,saturating_add_assign()
,store()
on an atomic counter is a race condition because it does not use the transactional properties of atomics. AlsoDelayVisibility
tombstones currently don't have their usage counter incremented on use.Summary of Changes
While
fetch_add()
gives up the saturating arithmetic, this is first of all an extremely improbable edge case as even with the wildest TPS numbers currently envisioned a single validator would still have to run for tens of thousands of years without a single reboot and all transactions only using a single program, for this 64 bit counter to ever overflow. And even if it does, the atomics do wrapping and do not panic, so it is self correcting.