On Feb 12, 9:16 am, Baz <[EMAIL PROTECTED]> wrote: > May not be your best bet, but can't you start a transaction and retry until > complete?
Well a transaction is good and useful, but it only contains writes, so it still allows Thread B to come along and read the old position values the instant before Thread A makes its UPDATEs. Then as Thread B finishes its UPDATEs based on the now out-of-date values, it screws things up. Of course this is super rare and may take millions of tries. My current app has 5 list items and one administrator, so not much of a worry. But if you have a lot of concurrent users then it could eventually happen. > On Feb 12, 2008 7:49 AM, sbeam <[EMAIL PROTECTED]> wrote: > > > > > On Feb 12, 5:59 am, wirtsi <[EMAIL PROTECTED]> wrote: > > > so I'll just go over to this thread with my problems :) > > > sorry for derailing your thread ;) > > > > ... > > > function beforeSave() > > > { > > > $this->query("LOCK TABLE {$this->table} AS Framejob WRITE, > > > {$this->table} WRITE, > > > queues AS Queue WRITE,jobcolumns as Jobcolumn > > > WRITE,storages as Storage WRITE, > > > lenscolors as Lenscolor WRITE,framecolors as > > > Framecolor WRITE,names as Name WRITE"); > > > > } > > > > Any idea what to do? > > > I think you are describing a classic race condition. > >http://en.wikipedia.org/wiki/Race_condition > > > A problem for sure, the list ordering may run perfectly for years and > > then blow up one day while you are on vacation. > > > I don't think you will be able to fix it with LOCK TABLES in mySQL. > > Hopefully you are using InnoDB anyway and it becomes irrelevant. LOCK > > TABLES can't prevent Thread B from reading the table, which is what > > you need to do. > > > In mySQL maybe you can try GET_LOCK() > > >http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#f... > > > So run "SELECT GET_LOCK('L1',10)" before you proceed. If Thread B > > comes along and needs to wait until Thread A is finished doing it's > > business, then it will (i think ---haven't tested) > > > how then to make it DB-agnostic is another issue. Anyone? > > > have fun > > Sam --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---