I am having a strange problem. I am trying to update a bunch of records
like this
a.each do |a|
b = Company.find_by_id(a.company_id)
b.col_name = Time.now
b.save
end
after I run this, I check the DB and the column “col_name” is indeed
updated. However, if I check the DB 5-10 minutes later, all changes are
gone. I’ve tried update_attribute, same problem.
after I run this, I check the DB and the column “col_name” is indeed
updated. However, if I check the DB 5-10 minutes later, all changes are
gone. I’ve tried update_attribute, same problem.
Try checking your configuration and verify that database auto-commit is
turned on.
Does anone know what else can be wrong with my DB? Every once in a
while my
Updates don’t get committed. The application was working fine all
morning,
but just now one update got rolled back again. My @@autocommit is
enabled,
I am not using any transactions, it’s a simple update.
Does anone know what else can be wrong with my DB? Every once in a while
my Updates don’t get committed. The application was working fine all
morning, but just now one update got rolled back again. My @@autocommit is
enabled, I am not using any transactions, it’s a simple update.
It appears your code is not checking the result of .save to see whether
validation failed.
I check save and it works fine. I check the DB after I run update and
the
records are updated (most of the time). However, every once in a while,
if
I check the table that was updated 5 minutes later, all changes are
rolled
back. I realized that it’s the issue with MySQL, not Rails. Is my
MySQL
missing some crucial configuration that I am not aware of?. I am using
MySQL 5, InnoDB and my @@autocommit is enabled. I posted a question on mysql.com several days ago but never got a single response.
I check save and it works fine. I check the DB after I run update and
the records are updated (most of the time). However, every once in a
while, if I check the table that was updated 5 minutes later, all
changes are rolled back. I realized that it’s the issue with MySQL, not
Rails. Is my MySQL missing some crucial configuration that I am not
aware of?. I am using MySQL 5, InnoDB and my @@autocommit is enabled.
I posted a question on mysql.comhttp://mysql.com several days ago but
never got a single response.
Any help would be greately appreciated.
I use MySQL 4.1 and 5, and I have never seen anything like you suggest.
Have you checked your rails logs to see if there are any
explicit rollbacks being called?
If you think it is MySQL you should reproduce the issue outside of
Rails/ActiveRecord and within MySQL client.
Also, what version of MySQL 5 are you running? Can you paste your MySQL
config also?
Zach
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
Yes, I can reproduce this error within MySQL client. So, it’s defintely
not
a Rails issue. I can only reproduce this error a few times a day,
usually
it works fine. I am running Version: ‘5.0.22’ on FC 5 and my
@@autocommit
is enabled.