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)
method_missing' from lib/script/find_spvs.rb:25:in block in ’
from lib/script/find_spvs.rb:22:in each' from lib/script/find_spvs.rb:22:in ’
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.
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.