You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am observing ActionPolicy::UnrecognizedScopeTarget occasionally upon the application's start. It happens for different models. A typical stacktrace is
vendor/bundle/jruby/2.5.0/gems/action_policy-0.3.1/lib/action_policy/policy/scoping.rb:105:in `resolve_scope_type': Couldn't infer scope type for Topic::ActiveRecord_Relation instance (ActionPolicy::UnrecognizedScopeTarget)
from vendor/bundle/jruby/2.5.0/gems/action_policy-0.3.1/lib/action_policy/behaviours/scoping.rb:28:in `authorization_scope_type_for'
from vendor/bundle/jruby/2.5.0/gems/action_policy-0.3.1/lib/action_policy/behaviours/scoping.rb:17:in `authorized_scope'
from app/controllers/topics_suggest_controller.rb:44:in `topic_load'
Where topic_load is
def topic_load
@topic = authorized_scope(Topic.all).find params[:id]
authorize! @topic
end
This never happens during tests or development, being it MRI or JRuby. The application production always runs under JRuby.
Experiments
Since JRuby has fair threads, I thought it could be caused by some lack of thread safety. I have seen a similar problem before rails/rails#23699 (comment) , and I already have a special Rails route to pre-warm the application after start up. So I have simply put the following into that controller action:
# warm up Action Policy scopes
authorized_scope(Post.all)
The errors are gone. This makes me think that a problem with tread-safety in resolving scopes is very likely.
Regards,
Alexander
The text was updated successfully, but these errors were encountered:
Environment
Ruby Version: JRuby 9.2.7
Framework Version (Rails, whatever): Rails 5.2.3
Action Policy Version: 0.3.1
What did you do?
I am observing
ActionPolicy::UnrecognizedScopeTarget
occasionally upon the application's start. It happens for different models. A typical stacktrace isWhere
topic_load
isThis never happens during tests or development, being it MRI or JRuby. The application production always runs under JRuby.
Experiments
Since JRuby has fair threads, I thought it could be caused by some lack of thread safety. I have seen a similar problem before rails/rails#23699 (comment) , and I already have a special Rails route to pre-warm the application after start up. So I have simply put the following into that controller action:
The errors are gone. This makes me think that a problem with tread-safety in resolving scopes is very likely.
Regards,
Alexander
The text was updated successfully, but these errors were encountered: