0

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:

  1. Could someone confirm this relates to "too many database connections at the same time"?

  2. What can I do about it, outside of trying to limit the amount of database calls?

Thanks in advance.

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
Christoffer
  • 2,271
  • 3
  • 26
  • 57
  • 2
    Check out a similar question here.. http://stackoverflow.com/questions/2979369/databaseerror-current-transaction-is-aborted-commands-ignored-until-end-of-tra (looks like you need to check your logs for the bad query) – Abram Apr 15 '13 at 06:39
  • Possible duplicate of http://stackoverflow.com/questions/2979369/databaseerror-current-transaction-is-aborted-commands-ignored-until-end-of-tra – Chris Travers May 16 '13 at 05:16
  • The basic problem, and pg-error, is the same and the possible solution similar (there is an error in the query, fix it). But how come I only see this when the visitor number peaks? How do I handle this type of error in Rails (I have never used 'rollback')? – Christoffer May 25 '13 at 02:09

0 Answers0