--
You received this message because you are subscribed to the Google Groups "RefactorRVA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to refactorrva...@googlegroups.com.
To post to this group, send email to refac...@googlegroups.com.
Visit this group at http://groups.google.com/group/refactorrva.
For more options, visit https://groups.google.com/d/optout.
Using lock in Activerecord causes a 'select ... for update'. This should cause any operations that occur outside of the existing transaction to wait on that lock to release. Is it possible you're not using lock within an explicit transaction?I'm with Charles on this one. What you want to do is better served by using explicit locking or via triggers/functions within the right transaction isolation levels. Your RDBMS (excluding MySQL MYISAM) is built to solve these types of problems much easier than in Rails.Further, it sounds like these "multiple SSH runs" are `rake` commands that loads the Rails environment? Are they creating multiple processes? If so, threads won't save you. In the case of a forked webserver (unicorn & some versions of passenger & puma), threads won't save you.
+1 for using UUID if possible.If there's a significant amount of logic around generating the number i.e. if you have to incorporate the specified date, the angle of saturn, eye of newt, etc. it might be simpler to write a small ruby process that runs outside the main app/rake task. This could accept the specified date and other relevant data as input and output a unique number.Might be more comfortable to stay in Ruby rather than learn the idiosyncrasies of whatever DB you're in, and would provide a simple single point of syncronization.initializing with value from DB is an exercise left to the reader :)
-Bob
+1 for using UUID if possible.If there's a significant amount of logic around generating the number i.e. if you have to incorporate the specified date, the angle of saturn, eye of newt, etc. it might be simpler to write a small ruby process that runs outside the main app/rake task. This could accept the specified date and other relevant data as input and output a unique number.Might be more comfortable to stay in Ruby rather than learn the idiosyncrasies of whatever DB you're in, and would provide a simple single point of syncronization.initializing with value from DB is an exercise left to the reader :)
-Bob
On Tue, Nov 17, 2015 at 7:42 PM, Jamie Orchard-Hays <jami...@gmail.com> wrote: