[20190416]exclusive latch测试脚本.txt

--//昨天做了shared latch的测试脚本,今天完善exclusive latch测试脚本,上个星期的测试我是手工执行的.
--//今天写一个脚本验证看看.相关链接:
http://blog.itpub.net/267265/viewspace-2641414/ => [20190415]关于shared latch(共享栓锁).txt
http://blog.itpub.net/267265/viewspace-2641497/ => [20190416]完善shared latch测试脚本2.txt

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

$ cat peek.sh
#! /bib/bash
# 参数如下:latch_name Monitoring_duration
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
/* 参数如下: @ 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 latch_free.sql
/*
     This file is part of demos for "Contemporary Latch Internals" seminar v.18.09.2010
     Andrey S. Nikolaev (Andrey.Nikolaev@rdtex.ru)
     http://AndreyNikolaev.wordpress.com

This query shows trees of processes currently holding and waiting for latches
     Tree output enumerates these processes and latches as following:
Process <PID1>
 <latch1 holding by PID1>
    <processes waiting for latch1>
       ...
 <latch2 holding by PID1>
    <processes waiting for latch2>
       ...
Process <PID2>
...
*/
set head off
set feedback off
set linesize 120
select sysdate from dual;
select   LPAD(' ', (LEVEL - 1) )
     ||case when latch_holding is null then 'Process '||pid
             else 'holding: '||latch_holding||'  "'||name||'" lvl='||level#||' whr='||whr||' why='||why ||', SID='||sid
       end
     || case when latch_waiting  is not  null then ', waiting for: '||latch_waiting||' whr='||whr||' why='||why
       end latchtree
 from (
/* Latch holders */
select ksuprpid pid,ksuprlat latch_holding, null latch_waiting, to_char(ksuprpid) parent_id, rawtohex(ksuprlat) id,
       ksuprsid sid,ksuprllv level#,ksuprlnm name,ksuprlmd mode_,ksulawhy why,ksulawhr whr  from x$ksuprlat
union all
/* Latch waiters */
select indx pid,null latch_holding, ksllawat latch_waiting,rawtohex(ksllawat) parent_id,to_char(indx) id,
       null,null,null,null,ksllawhy why,ksllawer whr from x$ksupr where ksllawat !='00'
union all
/*  The roots of latch trees: processes holding latch but not waiting for latch */
select pid, null, null, null, to_char(pid),null,null,null,null,null,null from (
select distinct ksuprpid pid  from x$ksuprlat
minus
select indx pid from x$ksupr where ksllawat !='00')
) latch_op
connect by prior id=parent_id
start with parent_id  is null;

2.测试:
--//上个星期测试的是'test excl. parent2 l0',继续拿它测试.
$ cat  x1.sh
#! /bin/bash
zdate=$(date '+%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 /nolog @ exclusive_latch.txt 'test excl. parent2 l0' 1 2 3 6 > /dev/null &
sleep 2
sqlplus /nolog @ exclusive_latch.txt 'test excl. parent2 l0' 1 4 5 6 > /dev/null &
sleep 2
sqlplus /nolog @ exclusive_latch.txt 'test excl. parent2 l0' 1 6 7 6 > /dev/null &
wait

$ grep  -v '^.*: $' /tmp/peekx_111121.txt | cut -c10- | uniq -c
      1  SYSDATE             LADDR
      1  ------------------- ----------------
      1  2019-04-16 11:11:21 0000000060009978
      1  Statement processed.
      6  [060009978, 060009980) = 00000023 00000000
      6  [060009978, 060009980) = 00000024 00000000
      6  [060009978, 060009980) = 00000025 00000000
      2  [060009978, 060009980) = 00000000 00000000

--//exclusive latch 是排他的,必须等其释放,其它进程才可以持有.
--//做一个测试,如果一个会话长时间持有已经死掉的情况下,oracle如何处理.

$ cat x2.sh
#! /bin/bash
zdate=$(date '+%H%M%S')
echo $zdate
source peek.sh 'test excl. parent2 l0' 320 | timestamp.pl >| /tmp/peekx_${zdate}.txt &
seq 320 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1'  | bash >| /tmp/latch_free_${zdate}.txt &
# 参数如下: @ exclusive_latch.txt latch_name willing why where sleep_num
sqlplus /nolog @ exclusive_latch.txt 'test excl. parent2 l0' 1 2 3 300 > /dev/null &
sleep 2
sqlplus /nolog @ exclusive_latch.txt 'test excl. parent2 l0' 1 4 5 6 > /dev/null &
sleep 2
sqlplus /nolog @ exclusive_latch.txt 'test excl. parent2 l0' 1 6 7 6 > /dev/null &
wait

--//执行x2.sh
$ . x2.sh
112841
..

$ pstree -ap
...
  |   |   |-sqlplus,5545 \040\040\040\040\040\040 @ exclusive_latch.txt test\040excl.\040parent2\040l0 1 2 3 300
  |   |   |   |-oracle,5595 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
  |   |   |   `-sleep,5726 300

$ kill -9 5595 5545

$ grep  -v '^.*: $' /tmp/peekx_112841.txt | cut -c10- | uniq -c
      1  SYSDATE             LADDR
      1  ------------------- ----------------
      1  2019-04-16 11:28:42 0000000060009978
      1  Statement processed.
    107  [060009978, 060009980) = 0000001B 00000000
      6  [060009978, 060009980) = 0000001C 00000000
      6  [060009978, 060009980) = 0000001E 00000000
    201  [060009978, 060009980) = 00000000 00000000

--//kill后后续的会话持有没有问题.估计pmon之类的进程会做清理工作.

[20190416]exclusive latch测试脚本.txt的更多相关文章

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

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

  2. [20190418]exclusive latch spin count.txt

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

  3. [20190423]oradebug peek测试脚本.txt

    [20190423]oradebug peek测试脚本.txt --//工作测试需要写一个oradebug peek测试脚本,不断看某个区域内存地址的值. 1.环境: SCOTT@book> @ ...

  4. [20190419]shared latch spin count.txt

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

  5. 锤子便签的 monkeyrunner 测试脚本(转)

    https://testerhome.com/topics/878 MonkeyRunner可能大家已经听过无数次了,大家在网上也看过了各种关于的它的资料了,我这里就不再过多的啰嗦它的用途了,它可以对 ...

  6. 【NO.11】Jmeter - 构建1个可供Linux使用的Jmeter测试脚本 - 共3个步骤

    在Linux使用Jmeter做性能测试需要4个前提条件,这4个前提条件已经在之前的文档里提到了,重复一下加深印象: (1) 在本地已安装xshell 参考<SecureCRT-转换密钥-Xshe ...

  7. [20180814]慎用查看表压缩率脚本.txt

    [20180814]慎用查看表压缩率脚本.txt --//最近看exadata方面书籍,书中提供1个脚本,查看某些表采用那些压缩模式压缩比能达到多少.--//通过调用DBMS_COMPRESSION. ...

  8. 记录项目代码迁移后,UI测试框架的搭建(配置文件的修改、测试脚本试运行)

    前文:记录一次项目代码迁移过程 上文代码迁移的目的就是为了新增vue脚手架自带的UI测试框架,工具有了,就需要实践运行在项目中了(修改配置文件.编写测试脚本等). 一.单元测试 测试框架 karma ...

  9. [20191013]oracle number类型存储转化脚本.txt

    [20191013]oracle number类型存储转化脚本.txt --//测试看看是否可以利用bc obase=100的输出解决问题.另外以前脚本忘记考虑尾数的四舍五入问题.--//也许编程就是 ...

随机推荐

  1. 简单计算器 安卓 Android 作业

    Android老师布置的课程作业——简单计算器 功能要求实现四则运算,参考界面见下图: 首先给各位老铁提供apk安装包以及项目压缩包,略表诚意~ github地址:https://github.com ...

  2. Android startActivity原理分析(基于Android 8.1 AOSP)

    应用进程内 如何使用Intent做Activity的跳转 Intnet intent = new Intent(MainActivity.this,TestActivity.class); start ...

  3. mssql sqlserver 三种数据表数据去重方法分享

    摘要: 下文将分享三种不同的数据去重方法数据去重:需根据某一字段来界定,当此字段出现大于一行记录时,我们就界定为此行数据存在重复. 数据去重方法1: 当表中最在最大流水号时候,我们可以通过关联的方式为 ...

  4. SQLServer存储过程自制数据字典

    相信很多小伙伴都对[数据字典]很头疼. 小编刚入职的时候,老大丢一个项目过来,就一个设计文档,数据字典木有,字段说明木有, 全部都需要靠“联系上下文”来猜.所以小伙伴门一定要养成说明字段的习惯哦. 说 ...

  5. python从学渣到学沫的半月天

    今天又要引进一个新的知识点了,就是模块,可以直接引用的一个东西,从实用性来说很强大,不过还是需要记住模块的类型啊,如何应用还是需要学习和了解的.其中模块是分三种的,一种内置模块python内部提供的功 ...

  6. Linux如何管理文档多租户

    例题 同一群组microsoft下的两个账号justmine001和justmine002需要共同拥有目录/microsoft/eshop的开发权,以便进行协同工作,但是其他人不允许进入和查阅该目录. ...

  7. 12.22 大湾区.NET Meet 大会

    今年的 Connect(); 主题更加聚焦开发者工具生产力.开源,以及无服务器(Serverless)云服务. Visual Studio 2019 AI 智能加持的 IntelliCode.实时代码 ...

  8. 群晖NAS再折腾

    端口转发 两年前我买了一台双盘位的群晖NAS,配置两个4T的硬盘,这玩意儿一度改变了我使用电脑的模式,真是爽爆了!最最主要的功能就是我能用它规整我所有的资料,并且不管何时何地,只要有网就能访问.为了能 ...

  9. Vs 中关于项目中的某 NuGet 程序包还原失败:找不到“xxx”版本的程序包“xxx”

    问题:     首先出现这个bug的是在我的vs2017社区版的ide上,这两天使用了出现了一个非常神奇的问题,就是我程序中的nuget包总提示找不到源文件,并且我点击Nuget还原的话还一直提示着一 ...

  10. PHP全栈学习笔记15

    PHP标记风格 PHP一共支持4种标记风格 <?php echo "这是XML风格的标记"; ?> 脚本风格 <script language="php ...