Re: Alternative MySQL PEAR DB sequence behavior
| From: | Tomas V.V.Cox | Date: | Wed, 25 Jul 2001 01:49:14 +0000 |
| Subject: | Re: Alternative MySQL PEAR DB sequence behavior | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-1035@lists.php.net to get a copy of this message | ||
"Stig S. Bakken" wrote:
>
> "Tomas V.V.Cox" wrote:
> >
> > "Stig S. Bakken" wrote:
> > >
> > > "Tomas V.V.Cox" wrote:
> > > >
> > > > "Stig S. Bakken" wrote:
Seems that we have "wrote" a lot :)
> > > > > Looks good (but I haven't run any concurrency tests), so I'll
> > > > > commit it.
> > > > >
> > > >
> > > > We should setup a basic test to use for example "ab" (Apache
> > > > Benchmark).
> > > > With it is easy to test concurrency problems.
> > >
> > > I think a good test would be somewhere around 50 simultaneous PHP
> > > requests that constantly generate sequence operations (so each request
> > > runs for, say, 30 seconds).
> > >
> >
> > I spend some time in this fun thing and done a mini test suite. This a
> > bash script (launch.sh) that launchs "n" php processes in background,
> > each of them will do "m" requests to the database. The first param is
> > the number of process and the second the number of request per process.
> >
> > In my tests I a good combination of both params was: ./launch.sh 100 100
> > (grater values may eat your resources, be careful).
> >
> > I know that it won't launch real simultaneous request, but seems to be
> > near it (a better sync system is welcome :), also it doesn't provide a
> > method to analyze the data.
>
> Hm, right now all concurrency.php does is to check whether nextId
> returns an error. The race condition occurs if the "UPDATE *_seq SET
> id=LAST_INSERT_ID(id+1)" statement is not atomic, so that mysqld reads
> the current value of the table in request 1, reads the current value is
> request 2, and then both update the sequence with the same value, and
> both requests think they have gotten unique ids.
My idea was to catch the output of the script and search for repeated
and non-consecutive values. My fear wasn't with UPDATE, was more with
the lock system and delete. I have the idea of using shared memory to
better syncronize processes. I know that probably this stuff won't serve
too much, but ...
Tomas V.V.Cox
PD.- I couldn't post here the scripts, so if someone want to get them
please drop me a email.