Sanjay Salunkhe
Sanjay Salunkhe

Reputation: 2733

How to increase connection timeout in rails?

I getting error as "could not obtain a database connection within 5.000 seconds (waited 5.000 seconds)" . i am trying to increase the timeout to 10 seconds by adding timeout field in database.yml file as below.

adapter: mysql2
  encoding: utf8
  pool: 10
  timeout: 10000
  username: root
  password: root

After adding timeout to 10 seconds i was expecting to get timeout of 10 seconds but still getting timeout of 5 seconds. it seems timeout is not set properly.

Upvotes: 0

Views: 2057

Answers (1)

Vasfed
Vasfed

Reputation: 18504

Timeout in settings control timeout on db connection itself, but you're having an error on rails being unable to get an idle connection from pool, because all 10 were busy for 5 seconds

Try increasing pool size. Also look into slow queries

For pool timeout - use checkout_timeout setting

Upvotes: 1

Related Questions