Skip to content

Loading…

Thread locking errors using Rack::JSONP #46

Closed
jasonschock opened this Issue · 0 comments

2 participants

@jasonschock

I have a very simple API using the Rack::JSONP module and am getting a 503 response with "recursive locking" error on my local development machine, as well as on Heroku. This happens with both Thin and WebBrick. The error happens quite often, sometimes every other request. As soon as I remove the callback= param from the query string, or remove the rack/contrib stuff from config.ru, no more problem. Sorry, don't know much about threads + rack, or why this might be happening.

  • Mac OS 10.7.2 and Heroku Cedar
  • Rails 3.1.3
  • Ruby 1.9.2-p290

My Gemfile (tried several gem versions):

...
gem 'rack-contrib', :git => 'git@github.com:rack/rack-contrib.git'
...

My config.ru:

...
require 'rack/contrib'
use Rack::JSONP
...

Sample request:

http://localhost:3000/api/v1/basket_items/new.json?callback=somecallback

My controller is very simple:

class Api::V1::BasketItemsController < Api::V1::BaseController
  respond_to :json

  def new
    respond_with BasketItem.new
  end

end

Sample error from WebBrick:

[2012-01-04 17:53:04] ERROR ThreadError: deadlock; recursive locking
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/lock.rb:14:in `lock'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/lock.rb:14:in `call'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.3/lib/action_dispatch/middleware/static.rb:53:in `call'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/engine.rb:456:in `call'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rack-contrib-acdcb256bb6e/lib/rack/contrib/jsonp.rb:31:in `call'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/content_length.rb:14:in `call'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/rack/log_tailer.rb:14:in `call'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/handler/webrick.rb:59:in `service'
    /Users/jason/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
    /Users/jason/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
    /Users/jason/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

Sample Heroku error (thin):

2012-01-05T02:03:53+00:00 app[web.1]: !! Unexpected error while processing request: deadlock; recursive locking
2012-01-05T02:03:53+00:00 heroku[router]: Error H13 (Connection closed without response) -> GET grasket-staging.herokuapp.com/api/v1/basket_items/new.json dyno=web.1 queue= wait= service= status=503 bytes=
@jasonschock jasonschock added a commit to Grasket/rack-contrib that referenced this issue
@jasonschock jasonschock [Issue #46] Added .close to response to resolve some thread locking i…
…ssues
5813d14
@rkh rkh closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.