[20190419]shared latch spin count 2.txt

--//上午测试shared latch XX模式的情况,链接:http://blog.itpub.net/267265/viewspace-2641902/
--//继续测试其它情况.
--//链接:http://andreynikolaev.wordpress.com/2011/01/14/spin-tales-part-2-shared-latches-in-oracle-9-2-11g/

S mode get  X mode get
Held in S mode  Compatible  2*_spin_count
Held in X mode           0  2*_spin_count
Blocking mode            0  2*_spin_count

1.环境:
SCOTT@book> @ ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SYS@book> @ hide spin_count
NAME              DESCRIPTION                        DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE
----------------- ---------------------------------- ------------- ------------- ------------
_mutex_spin_count Mutex spin count                   TRUE          255           255
_spin_count       Amount to spin waiting for a latch TRUE          2000          2000

$ cat shared_latch.txt
/* 参数如下: @ latch.txt latch_name willing why where mode sleep_num */
--//connect / as sysdba
col laddr new_value laddr
col vmode  new_value vmode
select decode(lower('&&5'),'s',8,'x',16,'8',8,'16',16) vmode from dual ;
SELECT addr laddr FROM v$latch_parent WHERE NAME='&&1';
oradebug setmypid
oradebug call kslgetsl_w 0x&laddr &&2 &&3 &&4  &vmode
host sleep &&6
oradebug call kslfre 0x&laddr
--//exit
--//注:我前几天的测试脚本有connect / as sysdba,exit这两行,我为了调式方便,先注解这2行,避免反复退出进入会话.

2.测试1:
--//选择一个shared latch测试,我选择"test shared non-parent l0" latch测试:
SYS@book> select * from shared_latches where name='test shared non-parent l0';
VERSION    LATCH# NAME                      S
---------- ------ ------------------------- -
11.2.0.4.0      6 test shared non-parent l0 Y

2.测试一些细节不再列出,参考链接:http://blog.itpub.net/267265/viewspace-2641902/
--//测试XS模式的情况:
--//session 1:
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 1 2 x 100000

--//session 2:
SYS@book> @ spid
       SID    SERIAL# PROCESS                  SERVER    SPID       PID  P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
         1         11 31454                    DEDICATED 31455       24          5 alter system kill session '1,11' immediate;
--//记下spid=31455.
SYS@book> @shared_latch.txt "test shared non-parent l0" 1 3 4 s 1
--//注意session 申请S mode.
--//window 3:执行:

$ rlwrap gdb -p 31455 -x spin_s.gdb
Breakpoint 1 at 0x93f97a8
Breakpoint 2 at 0x93f9b74
Breakpoint 3 at 0x9808932
Breakpoint 4 at 0x9809840
Breakpoint 5 at 0x37990d6400
Breakpoint 6 at 0x93f9ddc
Breakpoint 7 at 0x93faa36
Breakpoint 8 at 0xa865ca
Breakpoint 9 at 0xa874fa
Breakpoint 10 at 0xa875be
(gdb) c
Continuing.
...
kslgetl 6010d860, 1, 2126093176, 3991
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:96, mode:16
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:95, mode:8
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:96, mode:16
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:95, mode:8
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:96, mode:16
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:95, mode:8
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:3, why:4, mode:8
kslgess 60009a18, 8, 0, 3
kslskgs 60009a18, 0, 1129096976, 1129097520
kslskgs 60009a18, 0, 1129096976, 1129097520
---Type <return> to continue, or q <return> to quit---
skgpwwait 1129096760, 202182304, -2044672536, 0
sskgpwwait 1129096760, 202182304, -2044672536, 0
semop 315588608, 1129096560, 1, -1
--//按ctrl+c出现如下:
kslskgs 60009a18, 0, 1129096976, 1129097520

--//可以看出X模式的情况,申请S mode,第2进程直接调用semop.根本不做spin操作.

3.测试2:
--//测试SX模式的情况:
--//session 1:
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 1 2 s 100000
--//session 持有S mode.
 
--//session 2:
SYS@book> @shared_latch.txt "test shared non-parent l0" 1 3 4 x 1
--//注意session 申请x mode.
--//window 3:执行:
$ rlwrap gdb -p 31455 -x spin_s.gdb
..
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:95, mode:8
ksl_get_shared_latch laddr:85f7f4c8, willing:1, where:-2043602896, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:3, why:4, mode:16
kslgess 60009a18, 16, 0, 3
kslskgs 60009a18, 0, 1129096976, 1129097520
 spin count loop: 2000 a875be
 spin count loop: 1999 a875be
 spin count loop: 1998 a875be
 spin count loop: 1997 a875be
 ...
 spin count loop: 3 a875be
 spin count loop: 2 a875be
 spin count loop: 1 a875be
kslskgs 60009a18, 0, 1129096976, 1129097520
 spin count loop: 1 a875be
skgpwwait 1129096760, 202182304, -2044672536, 0
sskgpwwait 1129096760, 202182304, -2044672536, 0
semop 315588608, 1129096560, 1, -1
--//按ctrl+c后.
kslskgs 60009a18, 0, 1129096976, 1129097520
 spin count loop: 2000 a875be
 
--//可以S模式的情况,申请X mode,第2进程spin_count=2000.

4.测试3:
--//Blocking mode,首先我对这个模式的理解不是非常清晰.
--//我的理解
A.当前X mode持有,不管S,X模式申请都会阻塞,再有进程申请的情况.
B.当前S mode持有,X模式申请,后续再有进程申请的情况.
--//也就是这个情况至少3个会话,我分别测试看看
--//session 1:
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 1 2 s 100000

--//session 2:
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 3 4 x 1

--//session 3:
--//spid=31572
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 5 6 s 1

--//gdb监测session 3进程:
$ rlwrap gdb -p 31572 -x spin_s.gdb
...
ksl_get_shared_latch laddr:85f7fa68, willing:1, where:-2042914736, why:95, mode:8
ksl_get_shared_latch laddr:85f7fa68, willing:1, where:-2042914736, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:5, why:6, mode:8
kslgess 60009a18, 8, 0, 5
kslskgs 60009a18, 0, -1923148048, -1923147504
kslskgs 60009a18, 0, -1923148048, -1923147504
skgpwwait -1923148264, 202182304, -2044655416, 0
sskgpwwait -1923148264, 202182304, -2044655416, 0
semop 315588608, -1923148464, 1, -1
kslskgs 60009a18, 0, -1923148048, -1923147504
--//申请S mode,没有spin.

--//session 1:
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 1 2 s 100000

--//session 2:
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 3 4 x 1

--//session 3:
--//spid=31572
SYS@book> @ shared_latch.txt "test shared non-parent l0" 1 5 6 x 1

--//gdb监测session 3进程:
$ rlwrap gdb -p 31572 -x spin_s.gdb
...
ksl_get_shared_latch laddr:85f7fa68, willing:1, where:-2042914736, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:5, why:6, mode:16
kslgess 60009a18, 16, 0, 5
kslskgs 60009a18, 0, -1923148048, -1923147504
 spin count loop: 2000 a875be
 spin count loop: 1999 a875be
 spin count loop: 1998 a875be
 spin count loop: 1997 a875be
 ...
 spin count loop: 1 a875be
kslskgs 60009a18, 0, -1923148048, -1923147504
 spin count loop: 1 a875be
skgpwwait -1923148264, 202182304, -2044655416, 0
sskgpwwait -1923148264, 202182304, -2044655416, 0
semop 315588608, -1923148464, 1, -1
kslskgs 60009a18, 0, -1923148048, -1923147504
 spin count loop: 2000 a875be
--//申请X mode,spin_count=2000.

--//XSS的情况:
ksl_get_shared_latch laddr:85f7fa68, willing:1, where:-2042914736, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:5, why:6, mode:8
kslgess 60009a18, 8, 0, 5
kslskgs 60009a18, 0, -1923148048, -1923147504
kslskgs 60009a18, 0, -1923148048, -1923147504
skgpwwait -1923148264, 202182304, -2044655416, 0
sskgpwwait -1923148264, 202182304, -2044655416, 0
semop 315588608, -1923148464, 1, -1
kslskgs 60009a18, 0, -1923148048, -1923147504

--//XSX的情况:
ksl_get_shared_latch laddr:85f7fa68, willing:1, where:-2042914736, why:96, mode:16
ksl_get_shared_latch laddr:60009a18, willing:1, where:5, why:6, mode:16
kslgess 60009a18, 16, 0, 5
kslskgs 60009a18, 0, -1923148048, -1923147504
 spin count loop: 2000 a875be
 spin count loop: 1999 a875be
 spin count loop: 1998 a875be
 spin count loop: 1997 a875be
 spin count loop: 1996 a875be
 spin count loop: 1995 a875be
...
sskgpwwait -1923148264, 202182304, -2044655416, 0
semop 315588608, -1923148464, 1, -1
kslskgs 60009a18, 0, -1923148048, -1923147504
 spin count loop: 2000 a875be
--//总之:阻塞申请X mode,spin_count=2000.S mode 直接调用semop休眠.

5.总结
--//画一个表格:
                S mode get  X mode get
Held in S mode  Compatible  _spin_count
Held in X mode           0  _spin_count
Blocking mode            0  _spin_count

[20190419]shared latch spin count 2.txt的更多相关文章

  1. [20190419]shared latch spin count.txt

    [20190419]shared latch spin count.txt --//昨天测试exclusive latch spin count = 20000(缺省).--//今天测试shared ...

  2. [20190418]exclusive latch spin count.txt

    [20190418]exclusive latch spin count.txt--//昨天测试"process allocation" latch,主要这个latch与其它拴锁s ...

  3. [20190416]查看shared latch gets的变化.txt

    [20190416]查看shared latch gets的变化.txt 1.环境:SYS@book> @ ver1PORT_STRING                    VERSION  ...

  4. [20190416]完善shared latch测试脚本2.txt

    [20190416]完善shared latch测试脚本2.txt --//昨天测试shared latch,链接:http://blog.itpub.net/267265/viewspace-264 ...

  5. [20190415]关于shared latch(共享栓锁).txt

    [20190415]关于shared latch(共享栓锁).txt http://andreynikolaev.wordpress.com/2010/11/17/shared-latch-behav ...

  6. [20190505]关于latch 一些统计信息.txt

    [20190505]关于latch 一些统计信息.txt --//我在两篇文章,提到一些latch的统计信息.链接如下:http://blog.itpub.net/267265/viewspace-2 ...

  7. [20190319]shared pool latch与library cache latch的简单探究.txt

    [20190319]shared pool latch与library cache latch的简单探究.txt --//昨天看Oracle DBA手记3:数据库性能优化与内部原理解析.pdf 电子书 ...

  8. [20190416]11g下那些latch是Exclusive的.txt

    [20190416]11g下那些latch是Exclusive的.txt --//昨天测试了11g下那些latch是共享的,链接:--//是否反过来剩下的都是Exclusive的.继续测试: 1.环境 ...

  9. [20190415]10g下那些latch是共享的.txt

    [20190415]10g下那些latch是共享的.txt http://andreynikolaev.wordpress.com/2010/11/23/shared-latches-by-oracl ...

随机推荐

  1. Yii2设计模式——工厂方法模式

    应用举例 yii\db\Schema抽象类中: //获取数据表元数据 public function getTableSchema($name, $refresh = false) { if (arr ...

  2. postgresql 添加uuid扩展

    去年用EF Core做数据迁移到psql数据库的时候遇到了缺失uuid的错误,当时帅气的脸蛋突然懵逼了.现记录一下 以备参考. 环境:Centos7.2  psql  Xshell Xshell连接C ...

  3. Windows提示 错误: RPC 服务器不可用 解决方法。

    试验环境: 本地主机:win10  ip:192.168.0.10 远程主机: win2008 R2   ip:192.168.1.128 我想要通过systeminfo去获取远程主机的系统信息,但是 ...

  4. 一键解决更改计算机名后无法启动MSSQLSERVER服务问题

    问题版本:SQL Server 2012. 解决办法:打开服务,Win + R运行services.msc,找到 SQL SERVER(MSSQLSERVER)服务右键->属性,切换至登录选项卡 ...

  5. 通信(二):进程间通信之socket

    一.为什么要学习socket? 我们打开浏览器浏览网页时,浏览器的进程怎么与web服务器通信的?我们用QQ聊天时,QQ进程怎么与服务器或你好友所在的QQ进程通信?这些都得靠socket.本地的进程间通 ...

  6. 关于uni-app框架的学习-1

    根据官方文档进行学习Uni-APP, 再次过程中,记录一些需要熟悉的内容,有不合适的地方,见着都可知道,----我是一个小白,小白,小白 官网地址:https://uniapp.dcloud.io/ ...

  7. webpack打包nodejs项目(前端代码)

    PS.若本文没有帮到你可以看看我的进阶版点此前往 适用情况 首先说明,此情况不具备普遍性.若你的情况与笔者类似那么希望这篇文章能够帮到你. 我的项目情况是这样的:用node.js做后台,ejs做模板引 ...

  8. 【WebGIS系列】Typescript+WebGL+Webpack开发环境搭建

    目前Web实现矢量渲染的主流技术包括SVG.VML和WebGL.相对而言,VML是一种较古老的技术,虽然未成为W3C标准,但被早期的IE浏览器(IE9以下)和微软Office广泛使用,目前已经远离了浏 ...

  9. Java~类,抽象类和接口

    最近有空就着迷于java的世界,希望可以把自己的lind重构一个java版本出来,虽然遇到一些小问题,但也都解决了,还是那句话,知识需要积累,程序员需要一个追求! 类 抽象类 接口 泛型类 泛型接口 ...

  10. 大名鼎鼎的红黑树,你get了么?2-3树 绝对平衡 右旋转 左旋转 颜色反转

    前言 11.1新的一月加油!这个购物狂欢的季节,一看,已囊中羞涩!赶紧来恶补一下红黑树和2-3树吧!红黑树真的算是大名鼎鼎了吧?即使你不了解它,但一定听过吧?下面跟随我来揭开神秘的面纱吧! 一.2-3 ...