{"action":"created","issue":{"url":"https://api.github.com/repos/playframework/playframework/issues/6670","repository_url":"https://api.github.com/repos/playframework/playframework","labels_url":"https://api.github.com/repos/playframework/playframework/issues/6670/labels{/name}","comments_url":"https://api.github.com/repos/playframework/playframework/issues/6670/comments","events_url":"https://api.github.com/repos/playframework/playframework/issues/6670/events","html_url":"https://github.com/playframework/playframework/issues/6670","id":185283050,"number":6670,"title":"HTTP filters are executing on the Netty thread pool","user":{"login":"jroper","id":105833,"avatar_url":"https://avatars.githubusercontent.com/u/105833?v=3","gravatar_id":"","url":"https://api.github.com/users/jroper","html_url":"https://github.com/jroper","followers_url":"https://api.github.com/users/jroper/followers","following_url":"https://api.github.com/users/jroper/following{/other_user}","gists_url":"https://api.github.com/users/jroper/gists{/gist_id}","starred_url":"https://api.github.com/users/jroper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jroper/subscriptions","organizations_url":"https://api.github.com/users/jroper/orgs","repos_url":"https://api.github.com/users/jroper/repos","events_url":"https://api.github.com/users/jroper/events{/privacy}","received_events_url":"https://api.github.com/users/jroper/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-26T02:39:47Z","updated_at":"2016-10-27T00:55:54Z","closed_at":null,"body":"It appears that HTTP filters are now executing on the Netty thread pool. I'm not sure if this change was intentional or not, previously we ensured that they only executed on the Akka thread pool. Executing on the Netty thread pool is potentially very dangerous for end users, since Netty 4's threading model is to assign each connection a single thread from the thread pool, and execute all operations for that connection on that thread. The thread will be assigned to many connections at once, and so blocking on this thread will mean that every other connection associated with this thread will be blocked, even if the other threads in the pool are doing nothing. This is quite prone to deadlocks, which is why we probably shouldn't expose this thread pool to end users."},"comment":{"url":"https://api.github.com/repos/playframework/playframework/issues/comments/256518522","html_url":"https://github.com/playframework/playframework/issues/6670#issuecomment-256518522","issue_url":"https://api.github.com/repos/playframework/playframework/issues/6670","id":256518522,"user":{"login":"gmethvin","id":171663,"avatar_url":"https://avatars.githubusercontent.com/u/171663?v=3","gravatar_id":"","url":"https://api.github.com/users/gmethvin","html_url":"https://github.com/gmethvin","followers_url":"https://api.github.com/users/gmethvin/followers","following_url":"https://api.github.com/users/gmethvin/following{/other_user}","gists_url":"https://api.github.com/users/gmethvin/gists{/gist_id}","starred_url":"https://api.github.com/users/gmethvin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmethvin/subscriptions","organizations_url":"https://api.github.com/users/gmethvin/orgs","repos_url":"https://api.github.com/users/gmethvin/repos","events_url":"https://api.github.com/users/gmethvin/events{/privacy}","received_events_url":"https://api.github.com/users/gmethvin/received_events","type":"User","site_admin":false},"created_at":"2016-10-27T00:55:54Z","updated_at":"2016-10-27T00:55:54Z","body":"The issue I believe is at the Netty level we are using the trampoline execution context to actually execute the resulting action, rather than Play's default execution context. The relevant code is here: https://github.com/playframework/playframework/blob/master/framework/src/play-netty-server/src/main/scala/play/core/server/netty/PlayRequestHandler.scala#L257\r\n\r\nActions can define their own execution context, but EssentialActions cannot, so the actual body of the action will be executed in the same thread.\r\n\r\nIn 2.4.x the logic was quite different (due to changes in Netty and the move from iteratees to Akka streams). But the important part is that we executed the actual action in Play's default execution context: https://github.com/playframework/playframework/blob/2.4.x/framework/src/play-netty-server/src/main/scala/play/core/server/netty/PlayDefaultUpstreamHandler.scala#L210\r\n\r\nSo, I think we just need to switch the trampoline to Play's default EC in PlayRequestHandler. @jroper does that sound right?"}}
{"actor":{"display_login":"gmethvin"}}