Re: [jruby-user] Concurrency issues with JRuby on Rails

Chason Choate <[email protected]> Mon, 19 Jan 2015 16:11:19 -0600
Newsgroups gmane.comp.lang.jruby.user
Message-ID <CADgFOvqzxHqovbbGO_aWLd-GFDkwsWC+QzVZ+r0u8HuS7HFzew@mail.gmail.com>
Hey Bruce,

Thanks for the quick response.
1. The rails server is only taking 2-5 connections at this point in time.
We're testing atm.
    * No there are not many concurrent connections.
    * The requests do take a significant amount of time 20+ seconds.
(Returning json data hitting many different apis)
2. I am not aware of any AR calls outside of the typical rails controller
actions.
    * There may be a db leak but how do I tell? Is there a variable, etc I
can debug to print that info out? Remaining connections perhaps?
3. I could increase the pool higher but with the info above there is most
likely a leak or something going wrong with the connection pool.

We are also using threading in the action that is causing the issue. But we
have used the "with_connection" block before making any database calls in
the thread.

On Mon, Jan 19, 2015 at 3:43 PM, Bruce Adams <[email protected]> wrote:

>  It sounds like the twenty database connection you are allowing are all
> in use for more than 15 seconds.
>
> Is your Rails server under much load? (Are there many, concurrent
> requests? Are a bunch of those requests taking a long time (several
> seconds) to complete?)
> Is there a chance that your application is leaking database connections?
> That is, might their be code paths where a connection is taken from the
> database connection pool, but never returned to the pool?
>
> Can you increase the size of your database connection pool?
>
> - Bruce
>
> P.S. For what it's worth, I recommend a low checkout_timeout, specifically
> one second. I don't what a user request waiting around for resources.
> Fifteen seconds is a very long time for a user to wait for a web request.
> I'd rather give the user (and my own error logs) a message quickly when I
> run out of resources. With an error message, I get earlier notice that
> something isn't quite right.
>
> On Mon, Jan 19, 2015, at 04:28 PM, Chason Choate wrote:
>
> Hello there,
>
> I'm running into some concurrency issues and need some help. I'm currently
> using JRuby 1.7.12 and Rails 4.1.1. Every now and then i'm getting this
> error:
>
> ActiveRecord::ConnectionTimeoutError (could not obtain a database
> connection within 15.000 seconds (waited 15.001 seconds)):
>
>   vendor/bundle/jruby/1.9/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in
> `wait_poll'
>
> Our database pool is set to 20 and a checkout_timeout of 15.
>
> Has anyone seen this issue before?
> --
> Thanks,
> Chason Choate
>
>
>



-- 
Thanks,
Chason Choate