|
最初由 zhang_yong88 发布
[B]
1﹑oracle 是以什么方式來將 latch 置上不同的 level 的﹐是不可知的或是 按對 oracle 執行一個 動作 時順序所需要的 latch ....
2﹑這里的 level 是否有優先級的成份在里面....
3﹑在以 willing_to_wait 的方式去請求 latch 時﹐進程會先檢查是否已獲得 同一級或更高一級的 latch ﹐如果有則不能。。
這樣做是為了防止死鎖的發生﹐請問﹐1)。為何要限制是 同一級或更高級。 2)。為何要這樣來偵測死鎖﹐因為同一級的 latch 有多個﹐并不是兩個相互等待的 latch ﹐只是可能在同一級這種情況應是有的吧。顯然將死鎖的預測擴大了......
[/B]
I have not done much research on latch levels. Others may have better input. If your first question is about how Oracle determines what level a given latch should be on, well, we probably have to ask their kernel developers. They hard code level#'s with different latches. For instance, in 9i, library cache latches are at level 5 and shared pool latches are at 7, etc. I suppose they think a shared pool latch is more critical and should be held for a shorter time than a library cache latch. Yes, levels imply priority. As documentation says, a process, if it's holding a latch, cannot get a lower (or even equal) level latch. We can also say it your way: if the process wants to get a latch at level x, it checks to see if it already holds a latch >= x. If so, the attempt is aborted. Your last question is why >=x? Why not >x and allow latch gets at levels =x? Let's imagine this case:
i. Session 1 gets latch A
ii. Session 2 gets latch B
iii. 1 tries to get B
iv. 2 tries to get A
where A and B are at the same level x. If your rule only prohibits >x latch gets instead of >=x, then steps i through iv will all go through and a deadlock will occur. But if processes cannot hold latches A and B at the same time, i and ii work but steps iii and iv won't work (to be more correct, they won't work for willing to wait gets, not immediate gets).
On the other hand, if A's level is lower than B's, i through iii works but iv fails. A deadlock is also avoided.
Yong Huang |
|