Forum: Ruby on Rails MySQL transaction error, connection gone on COMMIT

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
3ef7363d1746826418e342e615644f6a?d=identicon&s=25 Andrew Gavin (Guest)
on 2007-02-17 04:55
(Received via mailing list)
We have a large site/application under construction in Ruby/Rails.
The site is currently running on Debian Etch 64 bit linux, and rails
1.2.2.  This problem is unchanged from rails 1.6 however (I upgraded
in the hope it would get fixed).  We are using the C "mysql" gem
library (latest version).

The database is MySql, 5.0.30.  Tables are all Inodb.  We currently
have 2 databases connected, although 1 contains only a log table is is
not used in the main application.

In summary I have been completely unable to get transactions to work
in a reliable manner.

Using ActiveRecord::Base.transaction &block      to surround
transactions, we frequently get "Mysql server has gone away" durring
the COMMIT command.   Without transactions there are no problems
(other than the fatally bad lack of transactions).  With them, they
fail to commit approximately 10-20% of the time.   The commit will
fail, throwing a "mysql gone" exception (which is normally caught by
the commit_db_transaction function).   Doing an ethereal trace on the
communication between rails and the db discovers that rails has issued
a QUIT directive in the middle of the transaction!!

Despite having studied the code in the abstract adapters and the mysql
adapter in much greater depth than I would ever like, I have not found
any reason why this should happen.

Anyone have any clue what is going on?  Are people using transactions
in this configuration with any sucess?

As an additional tidbit, or perhaps no relevance.  I tried rewriting
my own version of the transaction method, using the underlying
XX_db_transaction functions.  This doesn't get the error but seemingly
completly ignores my transactions (even though they are issued in the
SQL logs).   The normal transaction method works (80% of the time).

Andy Gavin
Flektor, Inc.
8da92d4ed91aa12535f6d870fa76b25e?d=identicon&s=25 Aaron (Guest)
on 2007-02-17 06:43
(Received via mailing list)
I work on a project that's running rails 1.2.2 with MySql.  Developers
use linux, mac, and windows.  We are using transactions to force
rollbacks in some of our functional tests, but we don't use the block
syntax.  Our code looks like this:

do stuff

Are you using any engines?  If so try disabling them and see if you
still have errors.  I doubt this is the problem because you said it
happened in 1.1.6, but its worth a try.

This topic is locked and can not be replied to.