I have been getting the following exception lately using the postgresql adapter. It seems to be related to Transactions, since it mentions BEGIN. I had a model named Transaction, which I thought might be causing the problem, so I renamed it to Transact. But I still get the error. Something is generating ''EXPLAIN BEGIN'' as the entirety of the SQL statement. The rails statement that is running is a dynamic finder: if v = Violation.find_by_issuer_id_and_filer_id(issuer.id, filer.id)> v << filingend>Anyone seen this? Any ideas? /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in> `async_exec'': PG::Error: ERROR: syntax error at or near "BEGIN" > (ActiveRecord::StatementInvalid) > LINE 1: EXPLAIN BEGIN > ^ > : EXPLAIN BEGIN > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in > `exec_no_cache'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:664:in > `block in exec_query'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:in > `block in log'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in > `instrument'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in > `log'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:663:in > `exec_query'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:538:in > `explain'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/explain.rb:65:in > `block (2 levels) in exec_explain'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/explain.rb:59:in > `tap'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/explain.rb:59:in > `block in exec_explain'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/explain.rb:58:in > `map'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/explain.rb:58:in > `exec_explain'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/explain.rb:34:in > `logging_query_plan'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/relation.rb:159:in > `to_a'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/relation/finder_methods.rb:378:in > `find_first'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/relation/finder_methods.rb:122:in > `first'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/relation/finder_methods.rb:264:in > `find_by_attributes'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/dynamic_matchers.rb:45:in > `method_missing'' > from lib/script/find_spvs.rb:29:in `block (2 levels) in <main>'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/associations/collection_proxy.rb:89:in > `each'' > from > /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/associations/collection_proxy.rb:89:in > `method_missing'' > from lib/script/find_spvs.rb:25:in `block in <main>'' > from lib/script/find_spvs.rb:22:in `each'' > from lib/script/find_spvs.rb:22:in `<main>'' > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/SSVCvuJ09oYJ. For more options, visit https://groups.google.com/groups/opt_out.
On 28 August 2012 17:14, ddoherty03 <ddoherty03-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have been getting the following exception lately using the postgresql > adapter. It seems to be related to Transactions, since it mentions BEGIN. > I had a model named Transaction, which I thought might be causing the > problem, so I renamed it to Transact. But I still get the error. Something > is generating ''EXPLAIN BEGIN'' as the entirety of the SQL statement. > > The rails statement that is running is a dynamic finder: > > >> if v = Violation.find_by_issuer_id_and_filer_id(issuer.id, filer.id) >> v << filing >> >> end > > > > Anyone seen this? Any ideas? > > >> >> /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in >> `async_exec'': PG::Error: ERROR: syntax error at or near "BEGIN" >> (ActiveRecord::StatementInvalid) >> LINE 1: EXPLAIN BEGIN >> ^ >> : EXPLAIN BEGIN >> from >> /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in >> `exec_no_cache'' >> from >> /home/ded/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:664:in > ...../collection_proxy.rb:89:in>> `method_missing'' >> from lib/script/find_spvs.rb:25:in `block in <main>'' >> from lib/script/find_spvs.rb:22:in `each'' >> from lib/script/find_spvs.rb:22:in `<main>''I assume that find_spvs.rb:25 is if v = Violation.find_by_issuer_id_and_filer_id(issuer.id, filer.id) If I were in that situation I would first extract issuer.id and filer.id to local variables just in case it is evaluating them that is causing a problem, and also put some debug in to print them just in case the values are strange. You have not said whether the Violation class works ok in other situations. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Colin, Thanks for the reply. I have checked out the issuer.id and filer.id variables and they look rational---they point to actual records---when the exception is thrown. I notice that the exception occurs at random points and seems to be independent of the data provided. I have temporarily solved the problem by catching the exception, sleeping one second, and issuing a retry, which appears to help. I recently updated ruby to 1.9.3 and rails to 3.2.8, so that may be the issue. Other than that, I''m stumped. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/YLEcr_ccXi8J. For more options, visit https://groups.google.com/groups/opt_out.
On 28 August 2012 21:51, ddoherty03 <ddoherty03-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Colin, > > Thanks for the reply. I have checked out the issuer.id and filer.id > variables and they look rational---they point to actual records---when the > exception is thrown. > > I notice that the exception occurs at random points and seems to be > independent of the data provided. > > I have temporarily solved the problem by catching the exception, sleeping > one second, and issuing a retry, which appears to help.Did you try googling for postgresql "explain begin" it brings up this which might be helpful http://stackoverflow.com/questions/10654329/rails-3-2-explains-causing-weird-issues-with-document-uploads Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Colin, I tried googling the error message with no hits. Thanks for the link. Regards, Dan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/0zgaPkDWlssJ. For more options, visit https://groups.google.com/groups/opt_out.
On 28 August 2012 23:02, ddoherty03 <ddoherty03-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Colin, > > I tried googling the error message with no hits. Thanks for the link.The trick where common words are involved can be to put the phrase in quotes to find exact matches, though it does not always work. Colin> > Regards, > > Dan > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/0zgaPkDWlssJ. > > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.