Christoffer
Christoffer

Reputation: 2411

PGError: ERROR: current transaction is aborted

Using: Rails 3.0.3 and Heroku with Postgresql.

I have been receiving numerous Exceptions such as this one:

A ActiveRecord::StatementInvalid occurred in home#index:

  PGError: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT "calculation_types".* FROM "calculation_types"
  .bundle/gems/ruby/1.9.1/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:202:in `rescue in log'

occuring althroughout my app but always when I perform as in this case

calculation_type = CalculationType.find(params[:id])

or similar, super simple, database-requests.

My list of gems (from when I uploaded it to Heroku):

   Installing rake (0.9.2.2) 
   Installing abstract (1.0.0) 
   Installing activesupport (3.0.3) 
   Installing builder (2.1.2) 
   Installing i18n (0.6.1) 
   Installing activemodel (3.0.3) 
   Installing erubis (2.6.6) 
   Installing rack (1.2.5) 
   Installing rack-mount (0.6.14) 
   Installing rack-test (0.5.7) 
   Installing tzinfo (0.3.33) 
   Installing actionpack (3.0.3) 
   Installing mime-types (1.19) 
   Installing polyglot (0.3.3) 
   Installing treetop (1.4.10) 
   Installing mail (2.2.19) 
   Installing actionmailer (3.0.3) 
   Installing arel (2.0.10) 
   Installing activerecord (3.0.3) 
   Installing activeresource (3.0.3) 
   Installing acts_as_tree_rails3 (0.1.0) 
   Installing breadcrumbs_on_rails (2.2.0) 
   Installing yamler (0.1.0) 
   Installing configatron (2.9.1) 
   Installing daemons (1.1.9) 
   Installing eventmachine (1.0.0) with native extensions 
   Installing exception_notification (2.4.1) 
   Installing friendly_id (4.0.0.beta12) 
   Installing i18n_routing (0.6.1) 
   Installing thor (0.14.6) 
   Installing railties (3.0.3) 
   Installing jquery-rails (1.0.19) 
   Installing pg (0.14.1) with native extensions 
   Installing postgres-pr (0.6.3) 
   Installing rack-rewrite (1.0.2) 
   Installing rack-timeout (0.0.3) 
   Using bundler (1.0.7) 
   Installing rails (3.0.3) 
   Installing thin (1.5.0) with native extensions 
   Installing time_diff (0.2.2) 

Facts

Questions

Q1. I don't even know where to start trouble shooting this (what other parts of my code would you need?). What should be my first steps?

Q2. Are there any known problems with Rails 3.0.3 and Postgresql?

Upvotes: 26

Views: 17516

Answers (3)

Travis Glover
Travis Glover

Reputation: 924

I just restarted my server. This cancelled the transaction.

Upvotes: 18

CezarBastos
CezarBastos

Reputation: 81

Can you perform a CalculationType.all or CalculationType.first without errors?

If you can access some data from this model, then reindexing your table could fix the problem, try this:

REINDEX TABLE <table_name>

or in rails console:

ActiveRecord::Base.connection.execute("reindex table <table_name>")

I had a similar problem a while ago, hope it helps.

Upvotes: 0

Chris Travers
Chris Travers

Reputation: 26464

This error is never your real problem. It occurs because you send a statement in a transaction that has already failed because of an upstream error. If you see a lot of these errors you want to go back in your log to find the first error in the stream, and it will be a different error.

Find this, and fix it. Note that this just means you are continuing transactions after other errors. The other errors are where the problems lie.

Upvotes: 19

Related Questions