rails/rails — Issue #4707: close your own AR connection warning: spurious?
Author: jrochkind
Created: 2012-01-26 18:18:23+00:00
State: open

I make use of app-created threads in a Rails 3.2 app.

As far as I can find, I am wrapping every single thing that could touch AR in a `ActiveRecord::Base.connection_pool.with_connection` block.

Nonetheless, I am getting deprecation warnings. Note that the one-line stack trace is inside the Rails stack, not my application code. (In the past, when I was doing something possibly wrong, I did get one-line traces in app code, so I know sometimes it does that).

[2012-01-26 13:10:49.322] WARN DEPRECATION WARNING: Database connections will not be closed automatically, please close your database connection at the end of the thread by calling `close` on your connection. For example: ActiveRecord::Base.connection.close
. (called from mon_synchronize at /home/rochkind/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211)

Now, I am creating threads and letting them run beyond the end of the request-response cycle, not waiting for them to join before returning response. While that may or may not be advisable from a performance standpoint, I believe it ought to be legal for AR. I mention this just because, maybe it's possible that's leading to spurious warnings?

Alternately, any hints for debugging and figuring out what's going on, or other ideas? Thanks for any help.