Thomas,hi!

On Tue, 9 Aug 2011 19:04:28 +0200
Thomas Mueller <[email protected]> wrote:

> Well, you seem to lock the tables in the wrong order. I would try to
> avoid deadlocks if ever possible. See the dining philosophers problem
> in Wikipedia. 

Yes, I'm aware of such problems as far as have dealt with heavy concurrency 
here [1] and in jdbc-wrapper I have wrote, but still wasn't aware of 
SQL-specific details.

[1] http://gaydenko.com/scala/tiscaf/httpd/

> You could use "select ... for update".

Thanks for the hint! It does the work. 

I'm not sure it is very interesting, but will describe the test. Db consists of 
two tables with 10 rows in each one - parents and children. Each parent has a 
single child, and visa versa. So we have 10 pairs. Each table also has integer 
field.

There are 50 threads (H2 is used in server mode, threads are not joined), each 
thread executes 10000 transactions. Each transaction consists of the steps:

- select random parent-child pair,
- increment that integer field in both participants (is used to check 
integrity).

In my test I have got all transactions successfully finished with tryCount set 
to 1. Excellent!! Say, without FOR UPDATE, with 10 threads, with tryCount set 
to 10 and 1000 millis between attempts I get ~99.96% of successfully finished 
transactions (of course, with kept integrity also).

Sorry for delay - I needed some time to seamlessly introduce FOR UPDATE into 
the wrapper.


Andrew

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to