> --
> You received this message because you are subscribed to the Google Groups "H2 Database" group.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to h2-database...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
>
Also the first statement on h2's website reads
"The MVCC feature allows higher concurrency than using (table level or
row level) locks."
And from this sentence one can deduce that mvcc is not the same as using
row level locks.
- rami
- rami
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
Cheers,
Jesse
>> And in this post Thomas says that the fail-fast behaviour isn't
>> present any more
It looks like a bug. Unfortunately I only fixed the 'update' case, and
not the 'insert' case. So trying to update the same row concurrently
will not fail immediately, but trying to insert two rows with the same
key does currently fail immediately (before the first transaction is
committed).
I will try to fix this problem for the next release (probably this weekend).
Regards,
Thomas
http://en.wikipedia.org/wiki/Multiversion_concurrency_control
As to exactly how H2 implements and uses MVCC, I can't comment on that. I don't know the details yet.
-James
On Aug 16, 2010, at 3:59 AM, Paul Hilliar wrote:
> I thought the purpose of MVCC was to give you row level locking not
> table level locking
>
At the same moment you can have many writers inserting or updating a row with the same primary key and every one see their own version of that row, in the mean while any reader still see the last committed version without blocking.
At commit time, MVCC require a fair ordering for serialization of pending commits with conflicts detection where some or all can get ordered committed and conflict's victims are rolled back.
For the case, two pending updates of the same row can be serialized but two pending inserts don't .
In MVCC the problem is to get a lock since MVCC is a database model, not an state. You must to use specific grammar like LOCK TABLE or SELECT ... WITH LOCK to get an concurrency contention effective & exclusive lock at row or table level ( it's a temporal
and scope limited suspension of MVCC).
I can't imagine how a db engine without parallel transaction processing capabilities (multi_threaded ++) would do MVCC.
In H2 terms , MVCC without MULTI_THREADED don´t seem to have much sense, you end locked on a row or blocked by serialized processing engine.
A database that I know has a reasonable MVCC implementation it's Postgresql, many others claim to be MVCC but in real use don't behave as if they were.
I hope help, regards.
Dario.
El 16/08/10 15:02, James Gregurich escribió: