well,the topic introduce Isolation in wikipedia have such words,links is here
......... Serializable This is the highest isolation level. With a lock-based concurrency control DBMS implementation, serializability requires read and write locks (acquired on selected data) to be released at the end of the transaction. Also range-locks must be acquired when a SELECT query uses a ranged WHERE clause, especially to avoid the phantom reads phenomenon (see below). When using non-lock based concurrency control, no locks are acquired; however, if the system detects a write collision among several concurrent transactions, only one of them is allowed to commit. See snapshot isolation for more details on this topic.
but whole topic didn't explain "range-locks",google alse have no accurate description.
what's "range-locks",and which different with "read lock" and "write lock"?
thanks!
The easiest way to use locking (not all databases use locking at all) to prevent concurrent operations colliding, is to lock an entire database. This would make everything one-by-one though, which would be terribly slow.
Next down, is if you lock a whole table. At least other tables aren't slowed down.
Narrowest is to lock a row. You can safely update that row and not block other operations.
A range lock is in between the last two. Cases where it's used include:
23
, so 23
identifies a range rather than a row).max(curvalue) + indexincrement
and ∞
).If you use a range in the WHERE
clause the database will lock each possible tuple in this range and also the next tuple (before and after). If there is no next tuple available in a direction it will lock completely in this direction.
So the SELECT
is reliable within the transaction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With