Frederick Cheung wrote: > On Jul 2, 11:10�am, Onur Gungor <[email protected]> > wrote: >> >> First I suspected that this problem is originating because Passenger was >> spawning processes and they are not sharing the mutex. But I checked the >> documentation but couldn't find a mention of it. And in this link >> (http://m.onkey.org/2008/10/23/thread-safety-for-your-rails) it says >> that it's OK to use Mutexes (though not mentioning the multiprocess >> passenger). >> > > Mutexes aren't for cross process synchronisation (unlike a mutex in > windows which can be shared across processes). > > Fred
OK. Then it means Mutex'es don't work in a multi-process Passenger setup. But then how can I synchronize this method's usage? I am very new to web development so I just heard about database locking. Simply, how should I use the ActiveRecord::Transactions::ClassMethods#transaction and ActiveRecord::Base#lock!? Would it be OK to create a model and its corresponding table for just locking? i.e. Lock model and locks table. Then use them like this: Lock.transaction do lock = Lock.find(1) lock.lock! # do my stuff which should be done by only one process at a time. end Thanks, Onur -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

