bjfish
(Brandon Fish)
April 29, 2022, 2:26pm
1
I believe there is a thread unsafe usage of a model instance where it appears to be sent to another thread here and later accessed concurrently:
Please review this thread which discusses the issue and a possible fix:
rails:main
β bjfish:attribute-set-builder-thread-safe
opened 07:28PM - 28 Apr 22 UTC
### Summary
While using rails in a multi-threaded Ruby implementation and se⦠rver (TruffleRuby/Puma), errors are produced by the unsafe hash usage in `AttributeSet::Builder`. This resolves the issue by using `Concurrent::Map` for `@casted_values`.
<!-- If there's anything else that's important and relevant to your pull
request, mention that information here. This could include
benchmarks, or other information.
If you are updating any of the CHANGELOG files or are asked to update the
CHANGELOG files by reviewers, please add the CHANGELOG entry at the top of the file.
Finally, if your pull request affects documentation or any non-code
changes, guidelines for those changes are [available
here](https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#contributing-to-the-rails-documentation)
Thanks for contributing to Rails! -->
<!--
Note: Please avoid making *Draft* pull requests, as they still send
notifications to everyone watching the Rails repo.
Create a pull request when it is ready for review and feedback
from the Rails team :).
-->
sam
(Sam Saffron)
May 2, 2022, 7:28am
2
I see β¦
Something like this I guess:
discourse:main
β discourse:defer_safety
opened 07:27AM - 02 May 22 UTC
Flagged by the truffle team at: https://meta.discourse.org/t/thread-unsafe-curre⦠nt-user-usage-in-auth-defaultcurrentuserprovider/225671
This usage of AR is unsafe currently, as AR models are not safe for concurrent usage
Introduces a new query potentially every minute which should be acceptable.
@daniel / @david / @tgxworld ?
It adds a new βfindβ query once a minute, but I guess this is acceptable since it will not happen every single request. I kept the old interface in place.
Can not easily be tuned further without breaking the plugin interface which would be a bit of a nightmare.
3 Likes