Closed
Description
When running grape on puma, all sorts of weirdness happens to the activerecord connection pool - things fail randomly and at times all the connections stay checked out, not leaving any connections in the pool.
The same code run on unicorn works just fine. It's worth noting that doing the same before/after thing with sinatra works fine on both puma and unicorn, so I think the problem is grape (rather than ActiveRecord or the DB driver).
Another odd thing happens when moving the 'after' block after the 'resource' block - then it is not run at all; but that's probably a separate issue.
class API < Grape::API
version 'v1', using: :header, vendor: 'foobar'
format :json
prefix '/api'
before do
ActiveRecord::Base.connection_pool.connections.map(&:verify!)
end
after do
ActiveRecord::Base.clear_active_connections!
end
resource :comments do
...
end
end