hi, i have problem with transactions and multiple databases. Object1 and Object2 are two different models/databases with different connections, when i use only one model: Object1.transaction do object1.value1 = "123456" object1.save do_some_error end it''s ok, error is produced, nothing is commited and database is unchanged. when i use 2 models, described at wiki.rubyonrails.com/rails/pages/HowToUseTransactions: Object2.transaction do Object1.transaction do object1.value1 = "123456" object1.save do_some_error end end - error is produced, but object1 is commited and database is changed - imho transaction is active(autocommit false) only for Object2 connection - ruby-1.8.4, rails-1.0, dbriver is oci any idea about this ? thanks, peter
The Agile Book addresses just this situation and advises against using ActiveRecord for updating multiple databases concurrently. What you are doing is a simulation of a true multiple database transaction. On 1/10/06, Petr Cervinka <petr.cervinka@gmail.com> wrote:> > hi, > i have problem with transactions and multiple databases. > > Object1 and Object2 are two different models/databases with different > connections, when i use only > one model: > > Object1.transaction do > object1.value1 = "123456" > object1.save > do_some_error > end > > it''s ok, error is produced, nothing is commited and database is unchanged. > > when i use 2 models, described at > wiki.rubyonrails.com/rails/pages/HowToUseTransactions: > > Object2.transaction do > Object1.transaction do > object1.value1 = "123456" > object1.save > do_some_error > end > end > > - error is produced, but object1 is commited and database is changed > - imho transaction is active(autocommit false) only for Object2 connection > - ruby-1.8.4, rails-1.0, dbriver is oci > > any idea about this ? > > thanks, peter > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: wrath.rubyonrails.org/pipermail/rails/attachments/20060110/53eccce4/attachment.html
On 11/01/2006, at 5:40 AM, Petr Cervinka wrote:> hi, > i have problem with transactions and multiple databases.For transactions across multiple databases to work right you need two- phase commit support. Rails doesn''t have two phase commit support, so even if it did work it wouldn''t do what you expect. -- Phillip Hutchings phillip.hutchings@sitharus.com