[ic] academic discussion about inventory under high checkout concurrency

Stefan Hornburg interchange-users@icdevgroup.org
Tue Oct 22 03:12:00 2002


On Tue, 22 Oct 2002 00:13:33 -0400
Mike Heins <mike@perusion.com> wrote:

> 
> Quoting Jeff Dafoe (jeff@badtz-maru.com):
> > 
> >     On a IC site with high checkout traffic it would also be necessary to
> > modify the admin interface.  The current admin interface saves inventory
> > modifications as absolute values.  If the inventory field indicates that you
> > have six items and you just received six, you put "12" in the box.  This
> > obviously wouldn't work on a site with crazy levels of checkout.  It would
> > be necessary to modify the inventory adjustment code on the admin side to
> > work on an adjustment basis, possibly storing the original inventory value
> > as a hidden form field.  Then if an inventory update was necessary it could
> > occur inside a db transaction where the current inventory value could be
> > read and modified by the appropriate amount in one atomic operation.
> 
> You wouldn't do those types of updates live. In fact, it is doubtful
> you should do inventory on IC at all, other than as an advisory...as I
> have said many times, IC is not an accounting system and doesn't pretend
> to be.
> 
> Any automatic inventory features have been put in by popular demand
> and with me kicking and screaming....I have never pretended that they
> were bulletproof.
> 
> That being said, there is an atomic increment of sorts in IC
> with
> 
>     [data table=inventory col=qty key="the_sku" increment=1 value=6]
> 
> You would want to put the DB in transactions mode first, of course.

You get the atomic increment on SQL databases with

update inventory set qty=qty+6 where key='the_sku'

instead of doing the calculation within IC.

At least that works with MySQL.

Bye
       Racke