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. Any idea what I am doing wrong? thanks, --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
> "eduard" wrote: > > 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. >Try checking your configuration and verify that database auto-commit is turned on. hth, Long --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Long, I checked, my autommit is set to 1. I am using MySQL. Any idea what else might be wrong? Thanks for your help, e On 8/28/06, Long <long755-bJEeYj9oJeDQT0dZR+AlfA@public.gmane.org> wrote:> > > > "eduard" wrote: > > > > 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. > > > Try checking your configuration and verify that database auto-commit is > turned on. > > hth, > > Long > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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. Thanks, On 8/28/06, eduard <fishkei-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Long, > > I checked, my autommit is set to 1. I am using MySQL. Any idea what else > might be wrong? > > Thanks for your help, > e > > > > On 8/28/06, Long <long755-bJEeYj9oJeDQT0dZR+AlfA@public.gmane.org> wrote: > > > > > > > "eduard" wrote: > > > > > > 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. > > > > > Try checking your configuration and verify that database auto-commit is > > turned on. > > > > hth, > > > > Long > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 8/29/06, eduard <fishkei-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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. jeremy --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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. Any help would be greately appreciated. thanks On 8/29/06, Jeremy Kemper <jeremy-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> wrote:> > On 8/29/06, eduard <fishkei-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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. > > jeremy > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 eduard wrote:> 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 <http://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 iD8DBQFE+kbbMyx0fW1d8G0RAmvCAJ0ehXpOL4d4LM3g3NrqOwM0ipfHqQCfSC0/ s0d3lnwKBNg2WM62dp715Rs=YaFu -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Zach, 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. here''s my my.cnf file ==============innodb_data_home_dir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Set buffer pool size to 50-80% of your computer''s memory, # but make sure on Linux x86 total memory usage is < 2GB innodb_buffer_pool_size=1G innodb_additional_mem_pool_size=50MB innodb_log_buffer_size=8MB skip-external-locking max_connections=200 read_buffer_size=1M sort_buffer_size=1M # Default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclient10 compatibility package). #old_passwords=1 #original, in my SQL 4.1 this didn''t work with Rails old_passwords=0 [mysql.server] user=mysql basedir=/var/lib [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---