{"action":"created","issue":{"url":"https://api.github.com/repos/puma/puma/issues/1707","repository_url":"https://api.github.com/repos/puma/puma","labels_url":"https://api.github.com/repos/puma/puma/issues/1707/labels{/name}","comments_url":"https://api.github.com/repos/puma/puma/issues/1707/comments","events_url":"https://api.github.com/repos/puma/puma/issues/1707/events","html_url":"https://github.com/puma/puma/issues/1707","id":398594291,"node_id":"MDU6SXNzdWUzOTg1OTQyOTE=","number":1707,"title":"Connection Timeout Error","user":{"login":"Sibgha228","id":26971711,"node_id":"MDQ6VXNlcjI2OTcxNzEx","avatar_url":"https://avatars2.githubusercontent.com/u/26971711?v=4","gravatar_id":"","url":"https://api.github.com/users/Sibgha228","html_url":"https://github.com/Sibgha228","followers_url":"https://api.github.com/users/Sibgha228/followers","following_url":"https://api.github.com/users/Sibgha228/following{/other_user}","gists_url":"https://api.github.com/users/Sibgha228/gists{/gist_id}","starred_url":"https://api.github.com/users/Sibgha228/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sibgha228/subscriptions","organizations_url":"https://api.github.com/users/Sibgha228/orgs","repos_url":"https://api.github.com/users/Sibgha228/repos","events_url":"https://api.github.com/users/Sibgha228/events{/privacy}","received_events_url":"https://api.github.com/users/Sibgha228/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-01-12T21:34:50Z","updated_at":"2019-05-04T16:21:23Z","closed_at":"2019-05-04T16:21:23Z","author_association":"NONE","body":"I am observing ActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 20.000 seconds (waited 2\r\n0.004 seconds)) which ultimately down the server. \r\n\r\nWe have 6 puma workers with minimum 0 and maximum 1 threads. The settings in database.yml are as following:\r\n  **adapter: postgresql\r\n  encoding: unicode\r\n  pool: 60\r\n  host: localhost\r\n  database: sample\r\n  username: \r\n  password: ENV['pg_pass']\r\n  idle_timeout: 300 \r\n  checkout_timeout: 20** \r\n\r\n\r\n### What has been already done to prevent the issue:\r\n1. Increased the pool size to 60\r\n2. Rake task to kill idle connections\r\n3. Skip filters for Error Controllers\r\n\r\nOnce I restart puma-manager the error disappear for next several hours. \r\n\r\n### System configuration\r\n\r\n**Ruby version**: 2.1.2\r\n**Rails version**: 4.1.5\r\n**Puma version**: 3.11.4\r\n\r\n### Full Backtrace\r\nActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 20.000 seconds (waited 20.004 seconds)):\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `block in wait_poll'\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `loop'\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `wait_poll'\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:136:in `block in poll'\r\n  /home/deploy/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:146:in `synchronize'\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:134:in `poll'\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:418:in `acquire_connection'\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'\r\n  /home/deploy/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'\r\n  /home/deploy/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'\r\n  activerecord (4.1.5) lib/active_record/connection_handling.rb:113:in `retrieve_connection'\r\n  activerecord (4.1.5) lib/active_record/connection_handling.rb:87:in `connection'\r\n  activerecord (4.1.5) lib/active_record/query_cache.rb:51:in `restore_query_cache_settings'\r\n  activerecord (4.1.5) lib/active_record/query_cache.rb:43:in `rescue in call'\r\n  activerecord (4.1.5) lib/active_record/query_cache.rb:32:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  actionpack (4.1.5) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'\r\n  activesupport (4.1.5) lib/active_support/callbacks.rb:82:in `run_callbacks'\r\n  actionpack (4.1.5) lib/action_dispatch/middleware/callbacks.rb:27:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  actionpack (4.1.5) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  actionpack (4.1.5) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  actionpack (4.1.5) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  railties (4.1.5) lib/rails/rack/logger.rb:38:in `call_app'\r\n  railties (4.1.5) lib/rails/rack/logger.rb:20:in `block in call'\r\n  activesupport (4.1.5) lib/active_support/tagged_logging.rb:68:in `block in tagged'\r\n  activesupport (4.1.5) lib/active_support/tagged_logging.rb:26:in `tagged'\r\n  activesupport (4.1.5) lib/active_support/tagged_logging.rb:68:in `tagged'\r\n  railties (4.1.5) lib/rails/rack/logger.rb:20:in `call'\r\n  quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  request_store (1.2.0) lib/request_store/middleware.rb:8:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  actionpack (4.1.5) lib/action_dispatch/middleware/request_id.rb:21:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  rack (1.5.5) lib/rack/methodoverride.rb:21:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  rack (1.5.5) lib/rack/runtime.rb:17:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  activesupport (4.1.5) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  actionpack (4.1.5) lib/action_dispatch/middleware/static.rb:64:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  rack (1.5.5) lib/rack/sendfile.rb:112:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  railties (4.1.5) lib/rails/engine.rb:514:in `call'\r\n  railties (4.1.5) lib/rails/application.rb:144:in `call'\r\n  newrelic_rpm (3.13.0.299) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'\r\n  puma (3.11.4) lib/puma/configuration.rb:225:in `call'\r\n  puma (3.11.4) lib/puma/server.rb:632:in `handle_request'\r\n  puma (3.11.4) lib/puma/server.rb:446:in `process_client'\r\n  puma (3.11.4) lib/puma/server.rb:306:in `block in run'\r\n  puma (3.11.4) lib/puma/thread_pool.rb:120:in `call'\r\n  puma (3.11.4) lib/puma/thread_pool.rb:120:in `block in spawn_thread'\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/puma/puma/issues/comments/489341304","html_url":"https://github.com/puma/puma/issues/1707#issuecomment-489341304","issue_url":"https://api.github.com/repos/puma/puma/issues/1707","id":489341304,"node_id":"MDEyOklzc3VlQ29tbWVudDQ4OTM0MTMwNA==","user":{"login":"nateberkopec","id":845662,"node_id":"MDQ6VXNlcjg0NTY2Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/845662?v=4","gravatar_id":"","url":"https://api.github.com/users/nateberkopec","html_url":"https://github.com/nateberkopec","followers_url":"https://api.github.com/users/nateberkopec/followers","following_url":"https://api.github.com/users/nateberkopec/following{/other_user}","gists_url":"https://api.github.com/users/nateberkopec/gists{/gist_id}","starred_url":"https://api.github.com/users/nateberkopec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nateberkopec/subscriptions","organizations_url":"https://api.github.com/users/nateberkopec/orgs","repos_url":"https://api.github.com/users/nateberkopec/repos","events_url":"https://api.github.com/users/nateberkopec/events{/privacy}","received_events_url":"https://api.github.com/users/nateberkopec/received_events","type":"User","site_admin":false},"created_at":"2019-05-04T16:21:23Z","updated_at":"2019-05-04T16:21:23Z","author_association":"MEMBER","body":"This is not a Puma issue. You have a (apparently very bad) ActiveRecord connection leak somewhere in your application. [Try this](https://stackoverflow.com/questions/36554988/how-to-debug-rails-connection-pool-usage)."}}
{"actor":{"display_login":"nateberkopec"}}