[20190423]简单测试latch nowilling等待模式.txt
[20190423]简单测试latch nowilling等待模式.txt
--//我对这个问题的理解就是如果参数willing=0,表示无法获取该latch,直接退出,再寻找类似的latch。
--//我仅仅知道redo copy latch具有这个特性:
> select addr,name,level#,latch#,gets,misses,sleeps,immediate_gets,immediate_misses,waiters_woken,waits_holding_latch,spin_gets,wait_time from v$latch_children where lower(name) like '%'||lower('redo copy')||'%' ;
ADDR NAME LEVEL# LATCH# GETS MISSES SLEEPS IMMEDIATE_GETS IMMEDIATE_MISSES WAITERS_WOKEN WAITS_HOLDING_LATCH SPIN_GETS WAIT_TIME
---------------- ---------- ------ ---------- ---------- ---------- ---------- -------------- ---------------- ------------- ------------------- ---------- ----------
00000012D720ADA8 redo copy 4 208 53 0 0 500627938 304381 0 0 0 0
00000012D720ACD0 redo copy 4 208 53 0 0 497827706 323330 0 0 0 0
..
00000012D72086D8 redo copy 4 208 53 0 0 491448415 365472 0 0 0 0
00000012D7208600 redo copy 4 208 53 0 0 508008338 391955 0 0 0 0
48 rows selected.
--//你可以发现nowait latch 的一个特点,就是IMMEDIATE_GETS会相对很高.注我查询的生产系统的情况.测试环境不会这么高的.
http://andreynikolaev.wordpress.com/2010/04/12/latch-internals-information-sources/
--//参数如下,另外我前面blog写错了,where是最后1个参数。
kslgetl(laddr, wait, why, where) – Get exclusive latch
More precisely, to request the latch Oracle kernel needs:
--//更准确地说,要请求闩锁Oracle内核需要:
laddress -- address of latch in SGA
wait -- flag. If true, this is latch get in willing-to-wait mode..
why -- context why the latch is acquired at this where.
where -- code for location from where the latch is acquired.
1.环境:
SYS@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
--//参考链接如下:http://blog.itpub.net/267265/viewspace-2641548/=>[20190416]exclusive latch测试脚本.txt
$ cat peek.sh
#! /bib/bash
# 参数如下:latch_name Monitoring_duration or laddr
sqlplus -s -l / as sysdba <<EOF
col laddr new_value laddr
SELECT sysdate,addr laddr FROM v\$latch_parent WHERE NAME='$1';
oradebug setmypid
$(seq $2|xargs -I{} echo -e 'oradebug peek 0x&laddr 8\nhost sleep 1' )
EOF
$ cat exclusive_latch.txt
/* 参数如下: @ exclusive_latch.txt latch_name willing why where sleep_num */
--//connect / as sysdba
col laddr new_value laddr
SELECT addr laddr FROM v$latch_parent WHERE NAME='&&1';
oradebug setmypid
oradebug call kslgetl 0x&laddr &&2 &&3 &&4
host sleep &&5
oradebug call kslfre 0x&laddr
--//exit
$ cat y1.sh
#! /bin/bash
zdate=$(date '+%Y%m%d%H%M%S')
echo $zdate
source peek.sh 'test excl. parent2 l0' 20 | timestamp.pl >| /tmp/peekx_${zdate}.txt &
seq 20 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >| /tmp/latch_freeo_${zdate}.txt &
# 参数如下: @ exclusive_latch.txt latch_name willing why where sleep_num
sqlplus / as sysdba <<< "@ exclusive_latch.txt 'test excl. parent2 l0' 0 1 2 6" > /dev/null &
sleep 2
sqlplus / as sysdba <<< "@ exclusive_latch.txt 'test excl. parent2 l0' 0 3 4 6" > /dev/null &
sleep 4.1
sqlplus / as sysdba <<< "@ exclusive_latch.txt 'test excl. parent2 l0' 0 5 6 6" > /dev/null &
wait
$ . y1.sh
20190424091250
[3]- Done sqlplus / as sysdba <<< "@ exclusive_latch.txt 'test excl. parent2 l0' 0 1 2 6" > /dev/null
[1] Done source peek.sh 'test excl. parent2 l0' 20 | timestamp.pl >|/tmp/peekx_${zdate}.txt
[4]- Done sqlplus / as sysdba <<< "@ exclusive_latch.txt 'test excl. parent2 l0' 0 3 4 6" > /dev/null
[5]+ Done sqlplus / as sysdba <<< "@ exclusive_latch.txt 'test excl. parent2 l0' 0 5 6 6" > /dev/null
[2]+ Done seq 20 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >|/tmp/latch_freeo_${zdate}.txt
2.测试:
$ grep -v '^.*: $' /tmp/peekx_20190424091250.txt | cut -c10- | uniq -c
1 SYSDATE LADDR
1 ------------------- ----------------
1 2019-04-24 09:12:50 0000000060009978
1 Statement processed.
6 [060009978, 060009980) = 00000015 00000000
1 [060009978, 060009980) = 00000000 00000000
6 [060009978, 060009980) = 00000015 00000000
7 [060009978, 060009980) = 00000000 00000000
--//你可以发现第1个会话申请成功,第2个会话没有申请成功,直接退出.第3个会话申请成功(因为sleep 2+4.1秒).
--//cat /tmp/latch_freeo_20190424091250.txt
2019-04-24 09:12:50
2019-04-24 09:12:51
Process 21
holding: 0000000060009978 "test excl. parent2 l0" lvl=0 whr=2 why=1, SID=295
2019-04-24 09:12:52
Process 21
holding: 0000000060009978 "test excl. parent2 l0" lvl=0 whr=2 why=1, SID=295
2019-04-24 09:12:53
Process 21
holding: 0000000060009978 "test excl. parent2 l0" lvl=0 whr=2 why=1, SID=295
2019-04-24 09:12:54
Process 21
holding: 0000000060009978 "test excl. parent2 l0" lvl=0 whr=2 why=1, SID=295
2019-04-24 09:12:55
Process 21
holding: 0000000060009978 "test excl. parent2 l0" lvl=0 whr=2 why=1, SID=295
2019-04-24 09:12:56
Process 21
holding: 0000000060009978 "test excl. parent2 l0" lvl=0 whr=6 why=5, SID=295
2019-04-24 09:12:57
Process 21
holding: 0000000060009978 "test excl. parent2 l0" lvl=0 whr=6 why=5, SID=295
2019-04-24 09:12:58
Process 21
holding: 0000000060009978 "test excl. parent2 l0" lvl=0 whr=6 why=5, SID=295
2019-04-24 09:13:00
Process 21
holding: 0000000060009978 "test excl. parent2 l0" lvl=0 whr=6 why=5, SID=295
2019-04-24 09:13:01
Process 21
holding: 0000000060009978 "test excl. parent2 l0" lvl=0 whr=6 why=5, SID=295
2019-04-24 09:13:02
Process 21
holding: 0000000060009978 "test excl. parent2 l0" lvl=0 whr=6 why=5, SID=295
2019-04-24 09:13:03
2019-04-24 09:13:04
--//21=0x15,与peek看到的一致.
3.手工测试看看函数的返回值
--//session 1:
SYS@book> @ exclusive_latch.txt 'test excl. parent2 l0' 0 1 2 60
old 1: SELECT addr laddr FROM v$latch_parent WHERE NAME='&&1'
new 1: SELECT addr laddr FROM v$latch_parent WHERE NAME='test excl. parent2 l0'
LADDR
----------------
0000000060009978
Statement processed.
Function returned 1
Function returned 0
--//session 2:
SYS@book> @ exclusive_latch.txt 'test excl. parent2 l0' 0 3 4 6
old 1: SELECT addr laddr FROM v$latch_parent WHERE NAME='&&1'
new 1: SELECT addr laddr FROM v$latch_parent WHERE NAME='test excl. parent2 l0'
LADDR
----------------
0000000060009978
Statement processed.
Function returned 0
ORA-00600: internal error code, arguments: [510], [0x060009978], [test excl. parent2 l0], [], [], [], [], [], [], [], [], []
--//可以发现申请成功函数返回值是1.失败是0.只所以session 2报错主要原因是没有申请成功,kslfre肯定报错.
4.看看latch统计信息的情况:
SYS@book> select addr,name,level#,latch#,gets,misses,sleeps,immediate_gets,immediate_misses,waiters_woken,waits_holding_latch,spin_gets,wait_time from v$latch_parent where lower(name) like '%'||lower('test excl. parent2 l0')||'%';
ADDR NAME LEVEL# LATCH# GETS MISSES SLEEPS IMMEDIATE_GETS IMMEDIATE_MISSES WAITERS_WOKEN WAITS_HOLDING_LATCH SPIN_GETS WAIT_TIME
---------------- --------------------- ------ ---------- ---------- ---------- ---------- -------------- ---------------- ------------- ------------------- ---------- ----------
0000000060009978 test excl. parent2 l0 0 5 4 0 0 4 3 0 0 0 0
--//重复测试:
$ . y1.sh
20190424094217
[3]- Done sqlplus / as sysdba <<< "@ exclusive_latch.txt 'test excl. parent2 l0' 0 1 2 6" > /dev/null
[1] Done source peek.sh 'test excl. parent2 l0' 20 | timestamp.pl >|/tmp/peekx_${zdate}.txt
[4]- Done sqlplus / as sysdba <<< "@ exclusive_latch.txt 'test excl. parent2 l0' 0 3 4 6" > /dev/null
[5]+ Done sqlplus / as sysdba <<< "@ exclusive_latch.txt 'test excl. parent2 l0' 0 5 6 6" > /dev/null
[2]+ Done seq 20 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >|/tmp/latch_freeo_${zdate}.txt
SYS@book> select addr,name,level#,latch#,gets,misses,sleeps,immediate_gets,immediate_misses,waiters_woken,waits_holding_latch,spin_gets,wait_time from v$latch_parent where lower(name) like '%'||lower('test excl. parent2 l0')||'%';
ADDR NAME LEVEL# LATCH# GETS MISSES SLEEPS IMMEDIATE_GETS IMMEDIATE_MISSES WAITERS_WOKEN WAITS_HOLDING_LATCH SPIN_GETS WAIT_TIME
---------------- --------------------- ------ ---------- ---------- ---------- ---------- -------------- ---------------- ------------- ------------------- ---------- ----------
0000000060009978 test excl. parent2 l0 0 5 4 0 0 6 4 0 0 0 0
--//可以发现IMMEDIATE_GETS增加2次,IMMEDIATE_MISSES增加1次.
$ . y1.sh
20190424094448
[3]- Done sqlplus / as sysdba <<< "@ exclusive_latch.txt 'test excl. parent2 l0' 1 1 2 6" > /dev/null
--//注意我修改为willing=1方式获取.
[1] Done source peek.sh 'test excl. parent2 l0' 20 | timestamp.pl >|/tmp/peekx_${zdate}.txt
[4]- Done sqlplus / as sysdba <<< "@ exclusive_latch.txt 'test excl. parent2 l0' 0 3 4 6" > /dev/null
[5]+ Done sqlplus / as sysdba <<< "@ exclusive_latch.txt 'test excl. parent2 l0' 0 5 6 6" > /dev/null
[2]+ Done seq 20 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >|/tmp/latch_freeo_${zdate}.txt
SYS@book> select addr,name,level#,latch#,gets,misses,sleeps,immediate_gets,immediate_misses,waiters_woken,waits_holding_latch,spin_gets,wait_time from v$latch_parent where lower(name) like '%'||lower('test excl. parent2 l0')||'%';
ADDR NAME LEVEL# LATCH# GETS MISSES SLEEPS IMMEDIATE_GETS IMMEDIATE_MISSES WAITERS_WOKEN WAITS_HOLDING_LATCH SPIN_GETS WAIT_TIME
---------------- --------------------- ------ ---------- ---------- ---------- ---------- -------------- ---------------- ------------- ------------------- ---------- ----------
0000000060009978 test excl. parent2 l0 0 5 5 0 0 7 5 0 0 0 0
--//可以发现gets增加1,IMMEDIATE_GETS增加1次,IMMEDIATE_MISSES增加1次.
--//我希望这个这个帖子对于理解latch的统计有所帮助.以前我对于这些统计参数的理解一片混乱.
--//大家可以适当调整sleep参数,测试看看各种情况.
[20190423]简单测试latch nowilling等待模式.txt的更多相关文章
- C语言怎么简单测试为大小端模式
作者:Slience_J 原文地址:https://blog.csdn.net/slience_j/article/details/52048267 1.什么是大小端模式? 大端模式,是指数据的高字节 ...
- [20190505]关于latch 一些统计信息.txt
[20190505]关于latch 一些统计信息.txt --//我在两篇文章,提到一些latch的统计信息.链接如下:http://blog.itpub.net/267265/viewspace-2 ...
- [20190211]简单测试端口是否打开.txt
[20190211]简单测试端口是否打开.txt --//昨天看一个链接,提到如果判断一个端口是否打开可以简单执行如下:--//参考链接:https://dba010.com/2019/02/04/c ...
- [20190423]那个更快的疑问3.txt
[20190423]那个更快的疑问3.txt --//前一阵子,做了11g在单表单条记录唯一索引扫描的测试,摘要如下:--//参考链接:http://blog.itpub.net/267265/vie ...
- [20190415]关于shared latch(共享栓锁).txt
[20190415]关于shared latch(共享栓锁).txt http://andreynikolaev.wordpress.com/2010/11/17/shared-latch-behav ...
- Latch free等待事件
Latch free等待事件的三个参数:p1-latch的地址:p2-latch编号:p3-请求次数.从oracle10g起,latchfree不再包含所有的latch等待,有些latch等待可能表现 ...
- [20190419]shared latch spin count 2.txt
[20190419]shared latch spin count 2.txt --//上午测试shared latch XX模式的情况,链接:http://blog.itpub.net/267265 ...
- [20190415]10g下那些latch是共享的.txt
[20190415]10g下那些latch是共享的.txt http://andreynikolaev.wordpress.com/2010/11/23/shared-latches-by-oracl ...
- [20190415]11g下那些latch是共享的.txt
[20190415]11g下那些latch是共享的.txt http://andreynikolaev.wordpress.com/2010/11/23/shared-latches-by-oracl ...
随机推荐
- C++对象生存期&&static
生存期,即从诞生到消失的时间段,在生存期内,对象的值或保持不变,知道改变他的值为止.对象生存期分为静态生存期和动态生存期两种. 静态生存期 指对象的生存期与程序运行期相同.在namespace中声明的 ...
- Bootstarp的安装以及简单的使用方法(pycharm中)
一.安装 首先打开Bootstarp的官网:https://v3.bootcss.com 下载完成后,解压压缩包,把解压后的文件导入pycham中 在HTML页面中的style中导入bootstrap ...
- 关于elementUi tab组件路由跳转卡死问题
好久没来了,周五项目终于要上线了(*^▽^*),上线之前测出一个很恶心的bug真真是... 项目:Vue + elementUi 后台管理项目 问题描述:登录后首次通过侧边栏路由跳转到主页面有ta ...
- Web地图导图总结
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1. 背景 地图端展示了各类制图效果,用户希望可以一键生成报表,其中核心 ...
- SQL Server的Linked Server支持使用SEQUENCE吗?
SQL Server的Linked Server支持使用SEQUENCE吗? SQL Server 2012开始支持序列(SEQUENCE),今天遇到有个同事咨询,能否在LINKED SERVER ...
- 【机器学习笔记五】聚类 - k均值聚类
参考资料: [1]Spark Mlib 机器学习实践 [2]机器学习 [3]深入浅出K-means算法 http://www.csdn.net/article/2012-07-03/2807073- ...
- 【RL-TCPnet网络教程】第40章 RL-TCPnet之TFTP客户端(精简版)
第40章 RL-TCPnet之TFTP客户端 本章节为大家讲解RL-TCPnet的TFTP客户端应用,学习本章节前,务必要优先学习第38章的TFTP基础知识.有了这些基础知识之后,再搞本章节 ...
- 清除过期日志的py脚本
本篇和大家分享的是一个清除过期日志的python脚本,年后第二篇希望对大家有帮助: 该python脚本创建的由来 代码及分析 crontab定时任务 该python脚本创建的由来 此由来,是在过年假期 ...
- 从壹开始前后端分离 [ vue + .netcore 补程 ] 三十一║ Nuxt终篇:基于Vuex的权限验证探究
缘起 哈喽大家好,今天周四啦,楼主明天要正式放假了,这里先祝大家节日快乐咯,希望在家里能继续研究点儿东西吧,今天呢是 nuxt 的最后一篇,主要是对权限登录进行研究,这一块咱们之前在说第一个项目的时候 ...
- golang中Context的使用场景
golang中Context的使用场景 context在Go1.7之后就进入标准库中了.它主要的用处如果用一句话来说,是在于控制goroutine的生命周期.当一个计算任务被goroutine承接了之 ...