-
Notifications
You must be signed in to change notification settings - Fork 270
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 indexing issue in ObservableMap
#4346
Conversation
Duh, great catch, not sure how we've missed that. |
Do you want me to come up with a fix? I'd gladly spend some time doing that. |
Absolutely, thanks! |
37d748a
to
f5443c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do a swap-remove and only update the position of the swapped value?
@bnjbvr just gave it a shot, the extra test cases now pass.
It's obviously not the best possible solution in terms of complexity, but I think it fulfills the criteria defined in the code comment quoted above. 😄 |
Signed-off-by: [email protected]
f5443c5
to
9bfaf81
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4346 +/- ##
==========================================
- Coverage 85.02% 85.00% -0.02%
==========================================
Files 274 274
Lines 30107 30089 -18
==========================================
- Hits 25599 25578 -21
- Misses 4508 4511 +3 ☔ View full report in Codecov by Sentry. |
Absolutely better indeed, why didn't I think of that?! You will still have to scan the entire Unfortunately, there's no |
It looks like I cannot even call EDIT: |
ObservableMap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is a good bandaid solution, and we can implement something using a manual swap-remove later, if needs be.
Thanks for the fix! |
Thanks for reviewing and merging this quickly. I feel like this fix warrants a 0.8.1 release on crates.io since the indexing issue leads to having |
Our plan is to do a release somewhere around the end of the month (Christmas maybe), which will include this fix. |
Any `.remove` operation called on a `ObservableMap` did not re-index `values` _after_ the removed position, which means any later operation on elements inserted after the previously removed key would either be fetched wrongly, or panic when using `.get_or_create`. This PR fixes these two related bugs and adds extra test cases. --------- Signed-off-by: [email protected] Co-authored-by: Benjamin Bouvier <[email protected]>
The client we're building is panicking on startups in some random cases with the following error message
Value should be present or has just been inserted, but it's missing
. There seems to be a pretty serious bug inobservable_map.rs
which I initially demonstrated with an extension of the existing unit tests in 6d6f8e4.Any
.remove
operation called on aObservableMap
will not re-indexvalues
after the removed position, which means any later operation on elements inserted after the previously removed key will either be fetched wrongly, or panic when using.get_or_create
.This PR fixes these two related bugs and adds extra test cases.