May not be your best bet, but can't you start a transaction and retry until
complete?

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#function_get-lock
>
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to