evanphx/puma — Issue #32: Java thread exception with concurrent requests
Author: bporterfield
Created: 2012-01-07 03:56:39+00:00
State: open

I'm trying to test out concurrent requests w/puma. I can successfully call each of the routes below individually. When I try to call the long one, then the short while the long is executing, one of two things seem to happen:

1. The short one never returns
2. The short one returns, then the long one (as I'd expect), but then I get a Java exception.

Code & exception below:

Ruby (w/RVM):

jruby 1.6.5 (ruby-1.9.2-p136) (2011-10-25 9dcd388) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]

Gemfile:

gem 'rack'
gem 'jruby-rack'
gem 'puma'
gem 'sinatra'
gem 'jdbc-mysql'
gem 'sequel'

config.ru:

require 'tester'
Tester.run!

tester.rb:

require 'sinatra/base'
require 'sequel'

class Tester < Sinatra::Base
set :server, :puma

get '/short' do
db = Sequel.connect("jdbc:mysql://localhost/test?user=root")
db.run "select sleep(1)"
"Hello!"
end

get '/long' do
db = Sequel.connect("jdbc:mysql://localhost/test?user=root")
db.run "select sleep(20)"
"Long Hello!"
end

end

Exception:

Exception in thread "RubyThread-5: /Users/bporterfield/.rvm/gems/jruby-1.6.5@2j/gems/puma-0.9.2-java/lib/puma/thread_pool.rb:49" java.nio.channels.IllegalBlockingModeException

Full rackup to stacktrace here: http://pastebin.com/PZ22bhx2