On 2013-02-27 15:54, Ryan How wrote:
Yeah, I've read that one a few times. It doesn't really explain a lot
of detail. It only says
"Note, however, that the write transaction does need to use locks"
I was just having a dumb moment... I mean what is the point of FOR
UPDATE if it doesn't get a lock?
The H2 Documentation says
"When using MVCC in this database, delete, insert and update
operations will only issue a shared lock on the table. An exclusive
lock is still used when adding or removing columns, when dropping the
table, and when using SELECT ... FOR UPDATE"
So just to clarify my understanding. I can update / insert / delete in
MVCC without getting exclusive locks, so really it doesn't block other
writers, and still ensures transaction isolation. ?
Correct. It's the OPTIMISTIC CONCURRENCY strategy applied to database
modifications.
It looks like this:
while (true) {
generate some changes
if (nothing else has modified the rows we're interested in) {
commit changes
break;
}
throw away changes
if (timed out)
throw exception;
}
If I do FOR UPDATE, it gets an exclusive lock (Table level?), so this
would block readers and writers. But I'm having trouble thinking of a
use case for this.
Sometimes MVCC needs help, or it have trouble making progress on highly
contended rows and tables.
Sessions can find themselves stuck in a retry loop for some time.
In particular, our MVCC implementation is not nearly as smart as
PostgreSQL or Oracle.
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.