1.Share Table Locks (S)锁
Caution:
Your transaction may or may not update the table later in the same transaction. However, if multiple transactions concurrently hold share table locks for the same table, no transaction can update the table (even if row locks are
held as the result of a SELECT... FOR UPDATE statement). Therefore, if concurrent share table locks on the same table are common, updates cannot proceed and deadlocks are common. In this case, use share row exclusive or exclusive table locks instead.
2.锁转换(Lock Conversion)
For example, assume that a transaction uses a SELECT statement with the FOR UPDATE clause to lock rows of a table. As a result, it acquires the exclusive row locks and a row share table lock for the table. If the transaction later updates one or more of the locked rows, the row share table lock is automatically converted to a row exclusive table lock.
锁升级(Lock escalation)
For example, if a single user locks many rows in a table, some databases automatically escalate the user's row locks to a single table. The number of locks is reduced, but the restrictiveness of what is being locked is increased.
3.死锁的解决办法
If a deadlock is detected, the session that was unlucky enough to find it aborts its lock request and rolls back its current statement in order to break the deadlock. Note that this is a rollback of the current statement only, not necessarily the entire transaction. Oracle places an implicit savepoint at the beginning of each statement, called the default savepoint, and it is to this savepoint that the transaction is rolled back in the first case. This is enough to resolve the technical deadlock. However, the interacting sessions may well
remain blocked.
注意当oracle探测到死锁的时候,并不是回滚整个事务,而只是回滚产生死锁的statement,利用了savepoint。
-savepoint:savepoint允许你在事务中创建一个标记点""(marked point),一个事务中可以有多个savepoint。
-rollback to
4.为何在存在外键约束时级联删除如此危险?
What is so dangerous about a cascading delete? A deleted child table might, in turn, have its own child tables. Even worse,the child tables could have table-level triggers that begin to fire. What starts out as a simple, single-record delete from a harmless table could turn into an uncontrollable torrent of cascading deletes and stored database triggers.
5.分布式事务如何处理死锁
For distributed transactions, Oracle is unable to distinguish blocking locks and deadlocks, because not all of the lock information is available locally. To prevent distributed transaction deadlocks, Oracle times out any call in a distributed transaction if it has not received any response within the number of seconds specified by the _DISTRIBUTED_LOCK_TIMEOUT parameter. This timeout
defaults to 60 seconds. If a distributed transaction times out, an ORA-2049 error is returned to the controlling session. Robust applications should handle this exception in the same way as local enqueue deadlocks.
6.ITL
interesting transaction list
block中关于事务信息的记录(包括list编号、回滚段地址、事务状态、事务在该block影响的记录条数等)
ITL是 consistents reads 的基础,根据ITL才能去回滚段中找变化前的数据
大事务才某些少量特定条件下可能ITL没有被及时更新为提交状态,需要延迟块清除,这样才能让进程识别到底是否需要去回滚段中获取变化前数据。
所以说ITL的不同步更新导致 delay block cleanout
每一个ITL 就对应一个SCN
7.Exclusive Locks和Share Locks区别
Exclusive Locks lock a resource exclusively, Share Locks can be acquired by more than one Session as long as the other Session holding a Share Lock have no open Transaction. A Share Lock can be "switched" from one Session to another.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21805468/viewspace-620439/ ,如需转载,请注明出处,否则将追究法律责任。