Our rails app is version 4.2 and we get request timeout exception (35s) intermittently. We used puma as our server and we are running it with 8 threads
Looking at the backtrace, it seems like the code is trying to get a connection from the connection pool
[GEM_ROOT]/gems/activerecord-4.2.11.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
260 # this is correctly done double-checked locking
261 # (ThreadSafe::Cache's lookups have volatile semantics)
262 @reserved_connections[current_connection_id] || synchronize do
263 @reserved_connections[current_connection_id] ||= checkout
264 end
and @reserved_connections[current_connection_id] is nil at this point so it calls synchronize on line 262.
and the code eventually hung on a ruby 2.4.0 monitor class
/usr/local/lib/ruby/2.4.0/monitor.rb:187:in `lock'
185 def mon_enter
186 if @mon_owner != Thread.current
187 @mon_mutex.lock
188 @mon_owner = Thread.current
189 @mon_count = 0
^ hung on line 187 above and timeout.
I was thinking that setting reaping_frequency would help, but it seems like this is more of a concurrency problem instead of a bad connection problem.
Any help/hints are appreciated.