背景

本文为oracle 11g latch系列的第三篇文章,继续深入学习latch,想要熟悉其原理,还是先了解下相关视图的含义,尔后进一步深入其中,
便于解决问题。
   
   本系列前2文链接如下:

oracle 11g latch之系列一
   http://blog.itpub.net/9240380/viewspace-1820418/

oracle 11g latch之v$latch系列二
   http://blog.itpub.net/9240380/viewspace-1820457/

结论

1,oradebug poke手工模拟shared pool latch虽然成功,但v$latchholder却一直没值,还是没有理解清晰latch的机制和v$latchholder的关系
2,没有子LATCH的LATCH的情况只在V$LATCH及V$LATCH_PARENT存储数据
  而有子LATCH的LATCH在v$latch及v$latch_parent和v$latch_childrent皆存储数据
3,模拟占有shared pool latch为
用oradebug模拟shared poo latch
SQL> select 'oradebug poke 0x'||addr||' 4 0x00000001;' from v$latch_children where latch#=293;

'ORADEBUGPOKE0X'||ADDR||'40X00000001;'
--------------------------------------------------------------------------------------------
oradebug poke 0x0000000060103C88 4 0x00000001;
oradebug poke 0x0000000060103BE8 4 0x00000001;
oradebug poke 0x0000000060103B48 4 0x00000001;
oradebug poke 0x0000000060103AA8 4 0x00000001;
oradebug poke 0x0000000060103A08 4 0x00000001;
oradebug poke 0x0000000060103968 4 0x00000001;
oradebug poke 0x00000000601038C8 4 0x00000001;

4,模拟释放shared pool latch为
oradebug poke 0x0000000060103C88 4 0x00000000;
oradebug poke 0x0000000060103BE8 4 0x00000000;
oradebug poke 0x0000000060103B48 4 0x00000000;
oradebug poke 0x0000000060103AA8 4 0x00000000;
oradebug poke 0x0000000060103A08 4 0x00000000;
oradebug poke 0x0000000060103968 4 0x00000000;
oradebug poke 0x00000000601038C8 4 0x00000000;

可见即1为占有,0为释放

测试

1,数据库版本
SQL> select * from v$version where rownum=1;

BANNER
----------------------------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

2,获取有子latch的测试latch
SQL> select addr,latch#,level#,name,hash,gets,misses,immediate_gets,immediate_misses,spin_gets from v$latch where gets >0 and immediate_gets>0 and rownum<=10;

ADDR                 LATCH#     LEVEL# NAME                                 HASH       GETS     MISSES IMMEDIATE_GETS IMMEDIATE_MISSES  SPIN_GETS
---------------- ---------- ---------- ------------------------------ ---------- ---------- ---------- -------------- ---------------- ----------
0000000060009720          2          8 post/wait queue                 823771719     685636       1383         858180             2479          0
0000000060009F38          9          7 process allocation             2600548697      22679          2           7624                0          0
000000006000A9E0         16          8 longop free list parent         853437045         96          0             88                0          0
000000006000CF38         28          4 enqueue hash chains            1456202064   11610594       4823            325                0          3
000000006000D3A0         33          6 SGA IO buffer pool latch       2719726273          1          0              1                0          0
00000000600101C8         70          0 active service list            4226341592    1931885         58          10716                1          9
00000000600178B0        137          7 Memory Management Latch        1808980316         26          0           6943                0          0
00000000600188A8        145          2 cache buffers lru chain        3559635447     177525        149         170932              140          0
0000000060019E38        149          5 checkpoint queue latch         4259362863     298484          1          81957                3          0
000000006001A620        150          1 cache buffers chains           3563305585  299012270      13426         182643               77       7195

10 rows selected.

可见上述的10个LATCH只有6个LATCH有有子LATCH,还有4个LATCH没有子LATCH
SQL> select latch#,count(child#) from v$latch_children where latch# in (select latch# from  v$latch where gets >0 and immediate_gets>0 and rownum<=10) group by latch# order by 2;

LATCH# COUNT(CHILD#)
---------- -------------
        28             1
        16             1
         2             7
       145            16
       149            16
       150          8192

6 rows selected.

v$latch和v$latch_parent存储数据是相同的,源自官方手册
SQL> select addr,latch#,level#,name,hash,gets,misses,immediate_gets,immediate_misses,spin_gets from v$latch where latch#=2;

ADDR                 LATCH#     LEVEL# NAME                                 HASH       GETS     MISSES IMMEDIATE_GETS IMMEDIATE_MISSES  SPIN_GETS
---------------- ---------- ---------- ------------------------------ ---------- ---------- ---------- -------------- ---------------- ----------
0000000060009720          2          8 post/wait queue                 823771719     702401       1412         879227             2545          0

SQL> select addr,latch#,level#,name,hash,gets,misses,immediate_gets,immediate_misses,spin_gets from v$latch_parent where latch#=2;

ADDR                 LATCH#     LEVEL# NAME                                 HASH       GETS     MISSES IMMEDIATE_GETS IMMEDIATE_MISSES  SPIN_GETS
---------------- ---------- ---------- ------------------------------ ---------- ---------- ---------- -------------- ---------------- ----------
0000000060009720          2          8 post/wait queue                 823771719        158          0              0                0          0

获取上述LATCH的子LATCH,可见有7个子LATCH,且每个子LATCH的地址和其父LATCH的地址各为不同
SQL> select addr,latch#,child#,level#,name,hash,gets,misses,immediate_gets,immediate_misses,spin_gets from v$latch_children where latch#=2 order by 3;

ADDR                 LATCH#     CHILD#     LEVEL# NAME                                 HASH       GETS     MISSES IMMEDIATE_GETS IMMEDIATE_MISSES  SPIN_GETS
---------------- ---------- ---------- ---------- ------------------------------ ---------- ---------- ---------- -------------- ---------------- ----------
00000000DF0E8E18          2          1          8 post/wait queue                 823771719          0          0              0                0          0
00000000DF0E8ED8          2          2          8 post/wait queue                 823771719          0          0              0                0          0
00000000DF0E8F98          2          3          8 post/wait queue                 823771719          0          0              0                0          0
00000000DF0E9058          2          4          8 post/wait queue                 823771719          0          0              0                0          0
00000000DF0E9118          2          5          8 post/wait queue                 823771719          0          0              0                0          0
00000000DF0E91D8          2          6          8 post/wait queue                 823771719     318043        822         437417             1505          0
00000000DF0E9298          2          7          8 post/wait queue                 823771719     382458        585         439529             1031          0

7 rows selected.

再看下余下LATCH的没有子LATCH的4个LATCH的情况
可见没有子LATCH的LATCH,只在V$LATCH及V$LATCH_PARENT存储数据
SQL> select addr,latch#,level#,name,hash,gets,misses,immediate_gets,immediate_misses,spin_gets from v$latch where latch#=9;

ADDR                 LATCH#     LEVEL# NAME                                 HASH       GETS     MISSES IMMEDIATE_GETS IMMEDIATE_MISSES  SPIN_GETS
---------------- ---------- ---------- ------------------------------ ---------- ---------- ---------- -------------- ---------------- ----------
0000000060009F38          9          7 process allocation             2600548697      23328          2           7789                0          0

SQL> select addr,latch#,level#,name,hash,gets,misses,immediate_gets,immediate_misses,spin_gets from v$latch_parent where latch#=9;

ADDR                 LATCH#     LEVEL# NAME                                 HASH       GETS     MISSES IMMEDIATE_GETS IMMEDIATE_MISSES  SPIN_GETS
---------------- ---------- ---------- ------------------------------ ---------- ---------- ---------- -------------- ---------------- ----------
0000000060009F38          9          7 process allocation             2600548697      23328          2           7789                0          0

SQL> select addr,latch#,child#,level#,name,hash,gets,misses,immediate_gets,immediate_misses,spin_gets from v$latch_children where latch#=9 order by 3;

no rows selected

再学习下v$latchholder

经用ORADEBUG POKE模拟shared pool latch,虽然成功,但始终v$latchholder没有数据,也就是说我对于v$latchholder理解不准确

会话1

可见当前没有进程或会话持有LATCH

pid为持latch的进程号,sid为持latch会话,laddr为latch地址,gets为请求LATCH的次数(以乐意等待或不乐意等待),这理还是没有掌握到如何模拟出v$latchholder的深一层使用
SQL>  select pid,sid,laddr,name,gets from v$latchholder;

no rows selected

SQL> select latch#,child#,name from v$latch_children where latch#=293 order by 2;

LATCH#     CHILD# NAME
---------- ---------- --------------------
       293          1 shared pool
       293          2 shared pool
       293          3 shared pool
       293          4 shared pool
       293          5 shared pool
       293          6 shared pool
       293          7 shared pool

7 rows selected.

SQL> select  pid,spid from v$process where addr=(select paddr from v$session where sid=(select sid from v$mystat where rownum=1));

PID SPID
---------- ------------------------------------------------
        31 7675

SQL> select sid from v$mystat where rownum=1;

SID
----------
       40

可见当前SHARE POOL LATCH的MISES为1931
SQL> select addr,latch#,level#,name,hash,gets,misses,immediate_gets,immediate_misses,spin_gets from v$latch where latch#=293;

ADDR                 LATCH#     LEVEL# NAME                                 HASH       GETS     MISSES IMMEDIATE_GETS IMMEDIATE_MISSES  SPIN_GETS
---------------- ---------- ---------- ------------------------------ ---------- ---------- ---------- -------------- ---------------- ----------
0000000060033B08        293          7 shared pool                    2276811941     607836       1931              0                0          0

SQL> select addr,latch#,level#,name,hash,gets,misses,immediate_gets,immediate_misses,spin_gets from v$latch where latch#=293;

ADDR                 LATCH#     LEVEL# NAME                                 HASH       GETS     MISSES IMMEDIATE_GETS IMMEDIATE_MISSES  SPIN_GETS
---------------- ---------- ---------- ------------------------------ ---------- ---------- ---------- -------------- ---------------- ----------
0000000060033B08        293          7 shared pool                    2276811941     618910       1931              0                0          0

会话2
SQL> select  pid,spid from v$process where addr=(select paddr from v$session where sid=(select sid from v$mystat where rownum=1));

PID SPID
---------- ------------------------------------------------
        30 7581

SQL> select sid from v$mystat where rownum=1;

SID
----------
       38

会话1
用oradebug模拟shared poo latch
SQL> select 'oradebug poke 0x'||addr||' 4 0x00000001;' from v$latch_children where latch#=293;

'ORADEBUGPOKE0X'||ADDR||'40X00000001;'
--------------------------------------------------------------------------------------------
oradebug poke 0x0000000060103C88 4 0x00000001;
oradebug poke 0x0000000060103BE8 4 0x00000001;
oradebug poke 0x0000000060103B48 4 0x00000001;
oradebug poke 0x0000000060103AA8 4 0x00000001;
oradebug poke 0x0000000060103A08 4 0x00000001;
oradebug poke 0x0000000060103968 4 0x00000001;
oradebug poke 0x00000000601038C8 4 0x00000001;

7 rows selected.

SQL> oradebug setmypid
Statement processed.
SQL> oradebug poke 0x0000000060103C88 4 0x00000001;
oradebug poke 0x0000000060103BE8 4 0x00000001;
oradebug poke 0x0000000060103B48 4 0x00000001;
oradebug poke 0x0000000060103AA8 4 0x00000001;
oradebug poke 0x0000000060103A08 4 0x00000001;
oradebug poke 0x0000000060103968 4 0x00000001;
BEFORE: [060103C88, 060103C8C) = 00000000
AFTER:  [060103C88, 060103C8C) = 00000001
SQL> BEFORE: [060103BE8, 060103BEC) = 00000000
AFTER:  [060103BE8, 060103BEC) = 00000001
SQL> BEFORE: [060103B48, 060103B4C) = 00000000
AFTER:  [060103B48, 060103B4C) = 00000001
SQL> BEFORE: [060103AA8, 060103AAC) = 00000000
AFTER:  [060103AA8, 060103AAC) = 00000001
SQL> BEFORE: [060103A08, 060103A0C) = 00000000
AFTER:  [060103A08, 060103A0C) = 00000001
SQL> BEFORE: [060103968, 06010396C) = 00000000
AFTER:  [060103968, 06010396C) = 00000001
SQL> oradebug poke 0x00000000601038C8 4 0x00000001;
BEFORE: [0601038C8, 0601038CC) = 00000000
AFTER:  [0601038C8, 0601038CC) = 00000001

会话2
SQL> create table t_latch(a int);
hang住了

会话1
SQL> select pid,sid,laddr,name,gets from v$latchholder;

no rows selected

但好像没有数据显示

会话1

释放shared pool latch
SQL> oradebug setmypid
Statement processed.
SQL> oradebug poke 0x0000000060103C88 4 0x00000000;
BEFORE: [060103C88, 060103C8C) = 00000001
AFTER:  [060103C88, 060103C8C) = 00000000
SQL> oradebug poke 0x0000000060103BE8 4 0x00000000;
BEFORE: [060103BE8, 060103BEC) = 00000001
AFTER:  [060103BE8, 060103BEC) = 00000000
oradebug poke 0x0000000060103B48 4 0x00000000;
BEFORE: [060103B48, 060103B4C) = 00000001
AFTER:  [060103B48, 060103B4C) = 00000000
SQL> oradebug poke 0x0000000060103AA8 4 0x00000000;
BEFORE: [060103AA8, 060103AAC) = 00000001
AFTER:  [060103AA8, 060103AAC) = 00000000
SQL> oradebug poke 0x0000000060103A08 4 0x00000000;
BEFORE: [060103A08, 060103A0C) = 00000001
AFTER:  [060103A08, 060103A0C) = 00000000
SQL> oradebug poke 0x0000000060103968 4 0x00000000;
BEFORE: [060103968, 06010396C) = 00000001
AFTER:  [060103968, 06010396C) = 00000000
SQL> oradebug poke 0x00000000601038C8 4 0x00000000;
BEFORE: [0601038C8, 0601038CC) = 00000001
AFTER:  [0601038C8, 0601038CC) = 00000000

会话2
ddl执行成功
SQL> create table t_latch2(a int);

Table created.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-1821684/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9240380/viewspace-1821684/

oracle 11g latch之v$latch系列三相关推荐

  1. Oracle 11g Dataguard 物理备库配置(三)之Dataguard broker配置

    Oracle 11g Dataguard 物理备库配置系列文档 Oracle 11g Dataguard 物理备库配置(一)之duplicate创建 Oracle 11g Dataguard 物理备库 ...

  2. oracle读书笔记之Oracle 11g R2 DBA操作指南(前三章)

    Oracle 11g R2 DBA操作指南是我学习的第一本讲述oracle数据库知识的书籍,在此记录下自己的学习笔记,对于书中的知识点本人通过实际操作进行验证. 1.Oracle数据库基础 1.1.关 ...

  3. RHEL5 Oracle 11G R2 RAC 静默安装 (三) rdbms安装 dbca 建库

    三, rdbms安装 1, vi .bash_profile 两边节点 [oracle@huy1 ~]$ vi .bash_profile   追加 点击(此处)折叠或打开 export EDITOR ...

  4. Oracle 11g Dataguard 物理备库配置(一)之Duplicate配置

    Oracle 11g Dataguard Duplicate物理备库配置(一)之物理备库创建配置 # ver:1.5 第五次修改 # modify: 2013.8.16 # author: koumm ...

  5. Oracle 11g Dataguard 物理备库配置(四)之broker snapshot standby测试

    Oracle 11g Dataguard 物理备库配置系列文档 Oracle 11g Dataguard 物理备库配置(一)之duplicate创建 Oracle 11g Dataguard 物理备库 ...

  6. hpunix oracle rac,Oracle 11g RAC Installtion for HP-UNIX(Itanium)-详

    Oracle 11g RAC Installtion for HP-UNIX(Itanium) 一.预安装 .............................................. ...

  7. Oracle 11g dataguard三种模式以及实时查询(Real-time query)功能设置

    之前我们讨论过<Linux Oracle 11g dataguard物理standby 配置过程>, 但是在实际过程中会遇到不同的问题,首先我们讨论下ORACLE DATAGUARD的三种 ...

  8. oracle数据库第八章答案,Oracle培训(三十)——Oracle 11g 第八章知识点小结——处理数据...

    Oracle培训(三十)--Oracle 11g 第八章知识点总结--处理数据 Oracle 11g 第八章知识点总结--处理数据 知识点预览 复习 处理数据 复习 --建表t_user create ...

  9. oracle 获取第三行,Oracle 11g 第三章知识点总结——单行函数

    Oracle 11g 第三章知识点总结--单行函数 知识点预览 单行函数 单行函数 1. SQL 函数 2.两种 SQL 函数 3.单行函数 a) 操作数句对象 b)接受函数返回一个结果 c)只对一行 ...

最新文章

  1. 9.65 最长上升子序列
  2. mysql常用linux命令大全_Linux-MySQL常用命令(示例代码)
  3. 【Bootstrap4前端框架+MySQL数据库】前后端综合实训【10天课程 博客汇总表 详细笔记】【附:所有代码】
  4. poj 2226 Muddy Fields(合理建图+二分匹配)
  5. linux内核装载vfs过程
  6. MATLAB 滤波函数的源代码
  7. SPSS实战:多因素方差分析(以随机区组设计为例)
  8. 空指针:Attempt to invoke virtual method java.util.List “XXX“ on a null object reference
  9. python中oserror winerror,在python中将WindowsError转换为OSError
  10. n9005zhuenb6 Android 5,三星Galaxy Note3(港版N9005)刷机与ROOT教程【详细介绍】
  11. 微信企业转账到银行卡
  12. 四大检索工具 和 论文查找网址大全
  13. 打印文字一边清晰而另一边不清晰的解决方法
  14. 深度之眼Pytorch打卡(十三):Pytorch全连接神经网络部件——线性层、非线性激活层与Dropout层(即全连接层、常用激活函数与失活 )
  15. hdu 杭电1429 胜利大逃亡(续)
  16. 微博登录接入出现错误码21322(重定向地址不匹配),其他解决方法
  17. Linux将正在运行的前台程序放到后台执行
  18. 大学c语言基础 Turbo C2.0 (32位/64位通用)
  19. JAVA网站视频播放不了_java视频播放网站小结
  20. 拍照应用竞争升级,坐拥15亿用户的美图如何打好防御战?

热门文章

  1. 随机Tiled Map的生成
  2. 如何制作并美化我们的微信公众号的二维码?
  3. 吉米_王:浅谈链表和顺序表
  4. Delphi 编写数字签名验证并获取签名信息
  5. OB0201 obsidian dataview插件使用
  6. 【BI学习心得10-时间序列实战】
  7. webView加载白屏
  8. 程序员和产品经理凡尔赛文学对话
  9. 工作日志之Sonar扫描错误处理-Sonar扫描结果入库 java.sql.BatchUpdateException: Incorrect string value: '\xF3\xA3\xAC\xB
  10. 源发行版17需要目标发行版17