rack/rack — Issue #349: ThreadError in application (deadlock; recursive locking) after enabling Rack::Deflater
Author: dvandersluis
Created: 2012-02-28 17:11:51+00:00
State: open

This seems to be related to #168, but I'm not sure if it's the same issue.

I recently updated my application to use Rack::Deflater instead of gzipping at the nginx level (due to a bug that appeared to be like http://tech.blog.aknin.name/2011/11/04/nginxgzip-module-might-silently-corrupt-data-upon-backend-failure/).

However, since then, I have been getting intermittent ThreadErrors in my nginx log, both on development and production:

```
[ pid=25362 thr=15769860 file=utils.rb:176 time=2012-02-22 17:10:40.782 ]: *** Exception ThreadError in application (deadlock; recursive locking) (process 25362, thread #):
from /srv/talentnest/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:14:in `lock'
from /srv/talentnest/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:14:in `call'
from /srv/talentnest/shared/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:132:in `forward'
from /srv/talentnest/shared/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:139:in `pass'
from /srv/talentnest/shared/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:151:in `invalidate'
from /srv/talentnest/shared/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:70:in `call!'
from /srv/talentnest/shared/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/context.rb:50:in `call'
from /srv/talentnest/shared/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/engine.rb:479:in `call'
from /srv/talentnest/shared/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/application.rb:220:in `call'
from /srv/talentnest/shared/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /srv/talentnest/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/deflater.rb:13:in `call'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:206:in `start_request_handler'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:171:in `block in handle_spawn_application'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/utils.rb:479:in `safe_fork'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:166:in `handle_spawn_application'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:180:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
from :10:in `synchronize'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/helper-scripts/passenger-spawn-server:99:in `

'
```

I believe all my gems are up-to-date:

```
*** LOCAL GEMS ***

passenger (3.0.11)
rack (1.4.1, 1.4.0, 1.3.6, 1.3.5)
rack-cache (1.1)
rack-mount (0.8.3)
rack-openid (1.3.1)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.1)
```