ITPUB??ì3
新一届的微软MVP评选已经开始,欢迎各位推荐!
ITPUB论坛 » Oracle专题深入讨论 » 请问library cache pin和library cache lock是latch吗

标题: [精华] 请问library cache pin和library cache lock是latch吗
  本主题由 biti_rainy 于 2008-6-24 20:51 加入精华 
离线 chandler_1983



精华贴数 1
个人空间 0
技术积分 127 (13792)
社区积分 0 (1770497)
注册日期 2008-5-6
论坛徽章:0
      
      

发表于 2008-6-20 20:09 
请问library cache pin和library cache lock是latch吗

请问library cache pin和library cache lock是latch吗?对这个问题一直很模糊!


只看该作者    顶部
离线 晶晶小妹
月是上弦


精华贴数 3
个人空间 6470
技术积分 1845 (884)
社区积分 9 (11709)
注册日期 2008-2-15
论坛徽章:2
现任管理团队成员数据库板块每日发贴之星    
      

发表于 2008-6-20 21:27 
不是,Library cache pin是Oracle内部针对共享池的内存块的一种锁。
一些内存块合在一起存贮了一种对象。比如游标,一般需要两个两个内存块,一个存贮一般信息,另一个存贮执行执行计划。需要有一个总的内存块来管理这些分散的内存块,一般称这个总的内存块为句柄。Library cache lock是针对这个句柄块的锁。


__________________
没有必胜的秘籍,没有方程式遵循
要赢~只有全身心的投入!



为了方便大家查阅,所有的文章都已转入空间

http://space.itpub.net/?13095417

请大家多多支持!
只看该作者    顶部
离线 chandler_1983



精华贴数 1
个人空间 0
技术积分 127 (13792)
社区积分 0 (1770497)
注册日期 2008-5-6
论坛徽章:0
      
      

发表于 2008-6-21 10:04 
感谢晶晶的回答,这个我知道,但是这些都是内存锁,难道latch不是锁内存的吗?


只看该作者    顶部
离线 晶晶小妹
月是上弦


精华贴数 3
个人空间 6470
技术积分 1845 (884)
社区积分 9 (11709)
注册日期 2008-2-15
论坛徽章:2
现任管理团队成员数据库板块每日发贴之星    
      

发表于 2008-6-21 12:30 
Library cache Lock/Pin和Latch都是锁,只不过它们的实现方式不一样。相比之下,大多数的Latch只是内存中的一些字节,通过在这些字节中设置某个值,代表Latch所保护的对象是否被占用,大部分闩没有等待者队列、占用者队列等队列,等等吧。Latch的工作方式和Library cache Lock/Pin不太一样。它们都是锁,只不过有些是暗锁,有些是明锁,就是这样吧,实现方式不同,因此就说锁的类型不同。

[ 本帖最后由 晶晶小妹 于 2008-6-21 12:32 编辑 ]


__________________
没有必胜的秘籍,没有方程式遵循
要赢~只有全身心的投入!



为了方便大家查阅,所有的文章都已转入空间

http://space.itpub.net/?13095417

请大家多多支持!
只看该作者    顶部
离线 Yong Huang
版主



精华贴数 2
个人空间 0
技术积分 4176 (340)
社区积分 129 (3006)
注册日期 2001-10-9
论坛徽章:6
现任管理团队成员ITPUB元老管理团队2006纪念徽章会员2006贡献徽章授权会员2008年新春纪念徽章
      

发表于 2008-6-22 03:18 
chandler_1983's question can also be looked at this way: What do the latches "library cache pin" and "library
cache lock" do and what's the difference between "latch free" wait event where the latches are these two
types and the "library cache pin" or "library cache lock" waits themselves? Do the numbers
v$latch.gets for library cache lock/pin or the numbers v$system_event.total_waits for them tell us
the actual number of library cache locks/pins we've had in the database since instance startup?

If you check v$latch for these two latches and compare with the same name wait events in
v$system_event, you'll see the two latches are get'ed much more frequently. I think the numbers
for the two latches in v$latch accurately reflect the actual pins/locks we've had. There's no
statistic in v$sysstat or v$sesstat for latch gets, probably because v$latch.gets serves the
purpose already. If the database is not too busy causing waits on them, the numbers in
v$system_event (or other wait related views) will not increment. In fact, v$latch.sleeps should be
equal to these latches' "latch free" waits because latch waits are the same as latch sleeps. You
can test on a quiet single-user database, with no jobs or scheduler jobs, and very quickly type
select name, gets, misses, sleeps, immediate_gets from v$latch where name in ('library cache pin',
'library cache lock'). You'll see the pin gets keep going up (by 2 in my 10.2.0.1 database) while
lock gets stay the same. The 2 pins must be due to this SQL itself. Values in v$system_event stay
the same.

Yong Huang

[ 本帖最后由 Yong Huang 于 2008-6-23 06:07 编辑 ]


只看该作者    顶部
离线 anycall2010
回味失败不是我风格


精华贴数 0
个人空间 2256
技术积分 2207 (716)
社区积分 77 (3953)
注册日期 2006-11-25
论坛徽章:8
授权会员2008北京奥运纪念徽章:帆船数据库板块每日发贴之星2008北京奥运纪念徽章:沙滩排球2008北京奥运纪念徽章:摔跤2008北京奥运纪念徽章:皮划艇静水
生肖徽章2007版:鸡ITPUB新首页上线纪念徽章    

发表于 2008-6-23 15:36 
恩,学习一下


__________________
blog: http://space.itpub.net/8334342/spacelist-blog
只看该作者    顶部
离线 晶晶小妹
月是上弦


精华贴数 3
个人空间 6470
技术积分 1845 (884)
社区积分 9 (11709)
注册日期 2008-2-15
论坛徽章:2
现任管理团队成员数据库板块每日发贴之星    
      

发表于 2008-6-23 17:21 
library cache pin latch和library cache lock latch好像在文档上看过,因为Library cache Lock/Pin都不是原子操作,因此为了不使在加或释放Library cache Lock/Pin时,有其他操作对它们进行打扰,因为使用Library cache Lock/Pin latch对加、释放Lock/Pin的过程加以保护。


__________________
没有必胜的秘籍,没有方程式遵循
要赢~只有全身心的投入!



为了方便大家查阅,所有的文章都已转入空间

http://space.itpub.net/?13095417

请大家多多支持!
只看该作者    顶部
在线/呼叫 biti_rainy
人生就是如此



精华贴数 37
个人空间 0
技术积分 110918 (4)
社区积分 11771 (123)
注册日期 2001-12-12
论坛徽章:41
现任管理团队成员ITPUB长老会成员ITPUB元老年度论坛发贴之星年度论坛发贴之星ITPUB北京九华山庄2008年会纪念徽章
管理团队2007贡献徽章参与2007年甲骨文全球大会(中国上海)纪念ITPUB北京香山2007年会纪念徽章管理团队2006纪念徽章会员2007贡献徽章会员2006贡献徽章

发表于 2008-6-23 19:21 
获得一个library cache lock,表示获得到一个 handle,可以是  null、share,exclusive 三种模式。 根据这个handle可以获得到object。

pin 则是表示拥有handle情况下,要真正地使用这些object,必须把这些object 钉在内存中,这也分了 null、share、exclusive三种模式。

所以tom曾经简单描述过:  lock, get a handle,是一个寻找的结果; pin,excute ,使用寻找到的结果


结合sql的执行,编译,ddl的发生等情况可以理解三种模式的可能意义。

至于yong huang的例子中 pin增加  lock不增加,可以看作是 执行次数增加,但是由于session已经获得handle 不需要重新去寻找获得(session已经 cached这个 cursor ,表示已经获得handle)


这时我的理解,有什么不对欢迎讨论。


__________________
眼界决定边界,态度决定高度
blog:
人生就是如此
只看该作者    顶部
离线 Yong Huang
版主



精华贴数 2
个人空间 0
技术积分 4176 (340)
社区积分 129 (3006)
注册日期 2001-10-9
论坛徽章:6
现任管理团队成员ITPUB元老管理团队2006纪念徽章会员2006贡献徽章授权会员2008年新春纪念徽章
      

发表于 2008-6-23 20:12 
I modified my text and specially added these words:

"the numbers [i.e. gets]
for the two latches in v$latch accurately reflect the actual pins/locks we've had. There's no
statistic in v$sysstat or v$sesstat for latch gets, probably because v$latch.gets serves the
purpose already. If the database is not too busy causing waits on them, the numbers in
v$system_event (or other wait related views) will not increment. In fact, v$latch.sleeps should be
equal to these latches' "latch free" waits because latch waits are the same as latch sleeps."

Yong Huang


只看该作者    顶部
离线 Yong Huang
版主



精华贴数 2
个人空间 0
技术积分 4176 (340)
社区积分 129 (3006)
注册日期 2001-10-9
论坛徽章:6
现任管理团队成员ITPUB元老管理团队2006纪念徽章会员2006贡献徽章授权会员2008年新春纪念徽章
      

发表于 2008-6-23 20:17 


QUOTE:
原帖由 biti_rainy 于 2008-6-23 05:21 发表
至于yong huang的例子中 pin增加  lock不增加,可以看作是 执行次数增加,但是由于session已经获得handle 不需要重新去寻找获得(session已经 cached这个 cursor ,表示已经获得handle)

Exactly! Can we guess what the 2 pins are for each execution? I type
select name, gets, misses, sleeps, immediate_gets from v$latch where name in ('library cache pin',
'library cache lock')
in quick succession and v$latch.gets for library cache pin goes up by 2. Why 2? One for x$kslld and one for x$ksllt, the two base table under v$latch?

Yong Huang


只看该作者    顶部
相关内容


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰广域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:010037号 联系我们 法律顾问