Fix PooledHashMap dropping live entries when an entry is removed during forEach#8499
Open
abdessattar23 wants to merge 1 commit into
Open
Fix PooledHashMap dropping live entries when an entry is removed during forEach#8499abdessattar23 wants to merge 1 commit into
abdessattar23 wants to merge 1 commit into
Conversation
|
|
9a1d1bb to
dae39c2
Compare
…ved during iteration
dae39c2 to
2d49da6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Noticed
PooledHashMap.forEachcan skip an entry if the callback removes the one it's currently on. It walks each bucket by index, soremove()shifts the next entry into the current slot andi++jumps over itThis bites
AsynchronousMetricStoragein REUSABLE_DATA mode: during collection it removes stale series while iterating, so a live series sharing a bucket with a stale one can get dropped from that cycle. For cumulative async that shows up as a gap then a jump in the output. (IMMUTABLE_DATA usesConcurrentHashMapand was fine. The code comment even says the map was picked to allow removal during iteration, it just wasn't holding up)Fix: iterate each bucket back-to-front so removing the current entry only shifts already-visited ones. Added tests at the map level (collision plus remove-while-iterating) and the storage level (live series survive when stale ones drop)