2. Multi-user concurrent and consistent access to the database
structure is the biggest challenge.
Locking and Concurrency ensures that every user can read and
change the data consistently.
Oracle is rather good at it.
3. LOCKING
A lock is a mechanism used to arrange concurrent access to a shared resource.
Oracle locks table data at the row level, but it also uses
locks at many other levels to provide concurrent
access to various resources.
4. LOCKING ISSUES
Lock mechanism have to some issues. It is caused by bad design.
+Lost Updates
+Pessimistic Locking
+Optimistic Locking
+Blocking
-Blockend Inserts
-Blocked Updates and Deletes
-Deadlocks
-Lock Escalation
6. Types of Lock
DML Lock : DML locks guarantee the integrity of the data accessed by multiple users
at the same time.
- TX(Transaction) Locks : A TX lock is acquired when a transaction initiates its
first change, and is held until the transaction performs a COMMIT or
ROLLBACK.
- TM Locks : These locks are used to ensure that the structure of a table is not
altered while you are modifying its contents.
7. DDL Locks : DDL locks are automatically placed against objects during a DDL
operation to protect them from changes by other sessions.
DDL locks are held for the duration of the DDL statement, and are released
immediately afterwards.
There are 3 kinds of DDL LOCK.
- Exclusive DDL Locks
- Share DDL Locks
- Breakable Parse Locks
8. Latches and Internal Locks : Latches and enqueues are lightweight serialization devices
used to coordinate multi-user access to shared data structures, objects and files.
Latches are locks that are held for extremely short periods of time, for example the t
me it takes to modify an in memory data structure.
9. Manual Locking
The SELECT...FOR UPDATE statement is the predominant method of manually
locking data.
We can also manually lock data using the LOCK TABLE statement.
You might use the LOCK TABLE IN EXCLUSIVE MODE statement if you were
writing a large batch update that would affect most of the rows in a given table, and
you wanted to be sure that no one would ʹblockʹ you.
10. What is Concurrency Control ?
Concurrency controls are the collection of functions that the database provides in
order to allow many people to access and modify data simultaneously.
The lock mechanism affects concurrency.
Oracle's multi-versioning model for read consistency is always applied at the statement
level and can also be applied at the transaction level.
11. TRANSACTION ISOLATION LEVEL
The SQL92 standard defines four levels of transaction isolation, with different
possible outcomes for the same transaction scenario.
These isolation levels are defined in terms of three phenomena that are either
permitted or not at a given isolation level:
- Dirty Read
- Non-Repeatable Read
- Phantom Read
12. Isolation Levels
Repeatable Read : Data that has been updated but has not yet been initialized cannot
be read or updated by other transactions until it has been committed.
Read Committed : Data that is being updated by other transactions cannot be read
until the update process is complete.
Read Uncommitted : Data that is being updated by other transactions but that has not
yet been updated can be read.
13. Serializable : This is generally considered the most restrictive level of transaction
isolation, but provides the highest degree of isolation.
Serializable transactions see only those changes that were committed at the time the
transaction began, plus those changes made by the transaction itself through INSERT,
UPDATE, and DELETE statements. Serializable transactions do not experience
nonrepeatable reads or phantoms.