越看越感觉,写得不错,精彩
请扩展阅读如下章节:
oracle latch自译文(一)
http://space.itpub.net/9240380/viewspace-631161oracle latch自译文(二)
http://space.itpub.net/?uid-9240380-action-viewspace-itemid-631300我们继续译文:
enqueue简介
我们来假设一处情景,仅有一个用户的数据库引擎
我们不需要任何locks,哪怕就至少用于并发目的的
然后我们想让我们的数据库过渡到支持更多用户
实行并发的最简单方法是什么呢?
一个简单(简约)的大锁(lock) ,它可以防止或保护对于任何共享资源的访问
但这一个锁可以让系统过渡到最好情况吗,支持更多用户吗
把lock锁分成多个pieces是非常有意义的:--注:pieces我译为片
1)每个片用于保护不同类型的资源,比如:
一个TM表锁
这种TM表锁用于保护被事务修改的行
一个MR锁保护对于数据文件状态及布局的更改
2)更进一步对于单一对象的分类也是必需的,避免不必要的竞争
这种所谓的enqueue(后我译为:入队)资源标识符也可以纳入到(属于)资源
一个hash表的slots来确认或标识一些资源
资源不是锁,它们只是通过锁得到的对象的占位符
唯一标识符(pk)与一个资源对应关系包括如下:
资源类型(tx,tm,mr,etc)
资源标识符1(id1)
补注:这些资源标识符用于划分(表示)不同的资源类型与对应独立的对象,比如:两个表都占用在内存中给他们分配的tm锁资源,那么id1指明table的对象id(v$lock_type具体表示对于每种资源类型id1/2的含义是什么)
资源标识符2(id2)
locks:
锁表示锁占用者与被锁定的资源之间一种关系
如果在单一资源(以兼容模式)出现很多锁占用者,这时对于每个对象仍旧只是一个资源,但多个锁结构指向这个资源
为何锁叫作入队?
这是因为,对于锁等待者,采用锁定架构实现一种排序的排队机制(不好译)
latches 和mutexes严格意义上讲,没用采用一种精密的排队机制
入队资源
v$resource(x$ksqrs)
入队锁
v$lock(x$ksqe)
入队资源类型
v$lock_type-- 记录着id1和id2的含义
@lt tx
诊断排错是一种简单合适的工具
v$session_wait
v$lock
Enqueue tracing events:--入队追踪事件
10704, 00000, "Print out information about what enqueues are being obtained" --10704,00000,打印显示得取入队的相关信息
// *Cause: When enabled, prints out arguments to calls to ksqcmi and
// ksqlrl and the return values.
// *Action: Level indicates details:
// Level: 1-4: print out basic info for ksqlrl, ksqcmi
// 5-9: also print out stuff in callbacks: ksqlac, ksqlop
// 10+: also print out time for each line
10706, 00000, "Print out information about global enqueue manipulation"---10706,00000,打印全局入队操作的相关信息
// *Cause: When enabled, prints out activity in ksi routines.
// *Action: INternal system parameter (_ksi_trace) can be used in addition
// to setting this event to limit output information on selected
// set of global enqueue server enqueue type(s)
// For example:
// _ksi_trace = RTXA
// output information only for RT and XA lock types.
//
// *Action: Level indicates details:
// 0-4: show args for each main call
// 5-9: also indicate callbacks
// 10+: also printout time for each line
DEADLOCK DETECTED
[Transaction Deadlock]
Current SQL statement for this session:
update t set object_id = 2 where wner = 'SH'
The following deadlock is not an ORACLE error. It is a
deadlock due to user error in the design of an application
or from issuing incorrect ad-hoc SQL. The following
information may aid in determining the deadlock:
Deadlock graph:
---------Blocker(s)-------- ---------Waiter(s)---------
Resource Name process session holds waits process session holds waits
TX-00070003-00000a4a 19 150 X 16 147 X
TX-0005002e-00000d63 16 147 X 19 150 X
session 150: DID 0001-0013-00000032 session 147: DID 0001-0010-00000452
session 147: DID 0001-0010-00000452 session 150: DID 0001-0013-00000032
Rows waited on:
Session 147: obj - rowid = 0001593C - AAAVk8AABAAARJFAAC
(dictionary objn - 88380, file - 1, block - 70213, slot - 2)
Session 150: obj - rowid = 0001593C - AAAVk8AABAAASG8AAj
(dictionary objn - 88380, file - 1, block - 74172, slot - 35)
Information on the OTHER waiting sessions:
Session 147:
pid=16 serial=625 audsid=-1 user: 0/SYS
O/S info: user: PORGAND\Tanel, term: PORGAND, ospid: 5900:2388, machine: MSHOME\P
program: sqlplus.exe
application name: sqlplus.exe, hash value=0
Current SQL Statement:
update t set object_id = 3 where object_type = 'TABLE'
End of information on OTHER waiting sessions
Slides, scripts and my blog: ---牛人blog,多看啊,我认为这篇文章讲得深入浅出
http://blog.tanelpoder.com
...I will post this session's sqlplus output there after the conference
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9240380/viewspace-631301/
,如需转载,请注明出处,否则将追究法律责任。