On 16/08/2010 15:49, Paul Hilliar wrote:
And in this post Thomas says that the fail-fast behaviour isn't
present any more
http://groups.google.com/group/h2-database/browse_thread/thread/56a0b36cacd33a1e

TM:>  This is no longer the case. I will change
TM:>  the documentation to: "If multiple connections
TM:>  concurrently try to update the same row, the
TM:>  database waits until it can apply the change,
TM:>  but at most until the lock timeout
TM:>  expires.". I hope it is understandable...

So all the more confusing that my initial test case seems to have the
fail fast behaviour


Hi Paul,

By default, H2 only allows one statement to be executed on the database at a time. It's not possible for the second transaction to wait for the first transaction's completion, as this would require multiple concurrent statements to be executed.

So:

1: tx1: insert row
2: tx2: insert row
3: tx1: commit

At line 2, tx2 should wait for tx1 to commit, but it cant, because tx1 cannot execute the statement on line 3 until the statement on line 2 is completed (one statement at a time).

Without MVCC, you get a lock timeout when tx2 waits for the lock (why, I dont know - it's not like anything can actually release the lock, I think you should get the exception immediately, without even a wait. Oh well, what's a few milliseconds between friends).

With MVCC, you get a unique key violation. I think this is wrong, since there is no such value in the table, at least no such value COMMITTED to the table. The problem is the same however, tx2 could not possible wait for the completion of tx1. I would say an immediate lock timeout exception, or concurrency problem exception would do here.

H2 can be configured to allow concurrent statements, by using the MULTI_THREADED=TRUE setting, but this is marked experimental (although Thomas has indicated it is much more tested now), and more importantly, you cant use MULTI_THREADED=TRUE with MVCC.

Cheers,
Jesse

--
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