I run a Rails app / website (Rails v.3.0.3) with some 10.000 pageviews a day but sometimes, when Digg.com or similar links to it, I get 2 or 3 times that traffic. When that happens I tend to get a problem with my postgres database on Heroku and I get an error message (through exception_notification) like this:
An ActiveRecord::StatementInvalid occurred in home#index:
PG::Error: ERROR: current transaction is aborted, commands ignored until end of transaction block : SELECT "c_types".* FROM "c_types"
.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.20/lib/active_record/connection_adapters/postgresql_adapter.rb:518:in `exec'
This error message never occurs otherwise but when I see it it is usually when I have abnormal amount of traffic. This cause me to believe that the database connection gets "overheated". This was my first Rails app and it is really not properly optimized with database requests so it seems likely.
My questions:
Could someone confirm this relates to "too many database connections at the same time"?
What can I do about it, outside of trying to limit the amount of database calls?
Thanks in advance.