--- On Fri, 3/12/10, Adam Heath <doo...@brainfood.com> wrote:
> Adrian Crum wrote:
> > --- On Fri, 3/12/10, Adam Heath <doo...@brainfood.com>
> wrote:
> >> Adrian Crum wrote:
> >>> --- On Fri, 3/12/10, Adam Heath <doo...@brainfood.com>
> >> wrote:
> >>>> Search for synchronized in
> >>>> ShoppingCart.  You'll fine a couple
> of
> >>>> spots that lock on cartLines, a few that
> lock in
> >> the class
> >>>> instance
> >>>> itself.  But then no other hits.
> >>>>
> >>>> However, tons of internal variables all
> need to be
> >> kept
> >>>> self-consistent with each other, so
> locking
> >> against just
> >>>> one or the
> >>>> other of those variables won't work.
> >>> These same problems exist in a number of
> classes - not
> >> just the shopping cart (take a look at
> SequenceUtil for some
> >> really scary code). That's why I suggested a
> synchronization
> >> best practices page that the community can
> follow.
> >>
> >> I have looked at SequenceUtil, and have a version
> lying
> >> around that is
> >> non-blocking.  I need to pull that out of the
> attic,
> >> and put it in my
> >> staging tree, and run with it for a while.
> > 
> > It would be cool if you could send it to me. I can get
> SequenceUtil to break fairly easily with my multi-threaded
> data loading modification - so I think it would be a good
> test for your code.
> 
> Was it an exception?  What kind of error was it?

Consistent random foreign key violations. Two records would get the same 
sequence number. Random in that different entities would be affected each time, 
and consistent in that it happens nearly every time.

Try running five or more threads against it on a multi-processor machine.





Reply via email to