-
Notifications
You must be signed in to change notification settings - Fork 263
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 crashes when encoding user models #1412
Commits on Apr 19, 2024
-
add test reproducing crash when encoding models with concurrency
* Adds two tests that encode Identity Model and Properties Model while their aliases and tags dictionary are written to. * The tests try to add data, clear data, and encode these models concurrently
Configuration menu - View commit details
-
Copy full SHA for 35f6ed8 - Browse repository at this point
Copy the full SHA 35f6ed8View commit details -
lock access to model dictionaries during encode
* Identity Model and Properties Model have access to their aliases and tags dictionary wrapped in a lock. However, this lock was missing from the encode method, and is necessary.
Configuration menu - View commit details
-
Copy full SHA for 8cdf446 - Browse repository at this point
Copy the full SHA 8cdf446View commit details -
No need to hydrate identity model twice
* I noticed we were always hydrating the same identity model twice. * This is because we are parsing a fetch user response, we end up hydrating the identity model twice, unnecessarily, which drives caching it twice as well. * We already hydrate the identity model attached to the request. * Here, we were hydrating it again if the current user is the same. However, if the current user is the same, the model is the same and has already been hydrated.
Configuration menu - View commit details
-
Copy full SHA for 8c28fba - Browse repository at this point
Copy the full SHA 8c28fbaView commit details -
Update Identity Model to cache itself less frequently
* Removing multiple aliases via `removeAliases(array)` will now be done in one go: - Creates one OSDelta that will be parsed by the executor into individual Remove Alias Requests - Caches the new aliases once instead of in a loop for each label to remove * Hydrating aliases will now be done in one go as well: - Now, cache the new aliases once at the end. Prior, we cache the aliases after each alias as we hydrate. * In addition, put the call to `self.set` outside of the tagsLock, since the call to `self.set` will drive encoding itself, which also requires the tagsLock. The UnfairLock does not handle nested locking.
Configuration menu - View commit details
-
Copy full SHA for ff4705a - Browse repository at this point
Copy the full SHA ff4705aView commit details -
* Drop UnfairLock and use NSRecursiveLock * UnfairLock is fast, but it doesn’t support recursive locking. So, it crashes whenever you lock it twice from the same thread. * So far, we haven't encountered this, but this is possible, especially if we are not careful about how changes are propagated up.
Configuration menu - View commit details
-
Copy full SHA for ac60efc - Browse repository at this point
Copy the full SHA ac60efcView commit details -
Move properties model's change propagation outside of the lock
* Keep the lock minimal, just around write and read access to the tags dictionary * Move the events-driving outside of the lock, that create Deltas and caches the model, etc.
Configuration menu - View commit details
-
Copy full SHA for db031ff - Browse repository at this point
Copy the full SHA db031ffView commit details -
* Adding tags with blank value will remove the tag
Configuration menu - View commit details
-
Copy full SHA for 98908ee - Browse repository at this point
Copy the full SHA 98908eeView commit details