首页 > 其他分享 >[20241108]跟踪library cache lock library cache pin使用gdb(11g)4.txt

[20241108]跟踪library cache lock library cache pin使用gdb(11g)4.txt

时间:2024-11-08 20:46:13浏览次数:4  
标签:11g -- lock cache library address ----------

[20241108]跟踪library cache lock library cache pin使用gdb(11g)4.txt

--//验证前面建立的gdb脚本确定library cache pin address是否正确.

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

--//grant execute on sys.dbms_lock to scott;
create procedure lcp
is
begin
sys.dbms_lock.sleep(3600);
end;
/

2.测试:
--//session 1:
SCOTT@book> exec lcp()

--//session 2:
SCOTT@book> @spid
==============================
SID                           : 53
SERIAL#                       : 31
PROCESS                       : 20523
SERVER                        : DEDICATED
SPID                          : 20524
PID                           : 27
P_SERIAL#                     : 15
KILL_COMMAND                  : alter system kill session '53,31' immediate;
PL/SQL procedure successfully completed.

SCOTT@book> set timing on

--//window 2:
$ rlgdb -f -p 20524 -x lkpn11g.gdb

--//session 2:
SCOTT@book> alter procedure lcp compile;
--//这样编译挂起!!

--//window 2:
kglGetS0 return pin address : 000000007ce3fdb8 000000007ce3fdb8
kgllkal count 49 -- handle address: 000000007c468fc8, mode: 3 kglnaobj address:0x7c469170:       "LCPSCOTT\210覭|"
kglGetS0 return lock address : 000000007c13b6d0 000000007c13b6d0
kglpnal count 22 -- handle address: 000000007c468fc8, mode: 3 kglnaobj address:0x7c469170:       "LCPSCOTT\210覭|"
kglGetS0 return pin address : 000000007c13b4d0 000000007c13b4d0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--//session 4:
SYS@book> @ ashtop event,p1raw,p2raw,p3raw 1=1 &min
    Total                                                                                                                                                            Distinct Distinct    Distinct
  Seconds     AAS %This   EVENT                                      P1RAW             P2RAW             P3RAW             FIRST_SEEN          LAST_SEEN           Execs Seen  Tstamps Execs Seen1
--------- ------- ------- ------------------------------------------ ----------------- ----------------- ----------------- ------------------- ------------------- ---------- -------- -----------
       60     1.0  100% | library cache pin                          000000007C468FC8  000000007C13B4D0  0001759800010003  2024-11-08 10:29:53 2024-11-08 10:30:52          1       60           1

--//P2raw就是pin的地址000000007C13B4D0,可以发现完全对上,没有问题.

SYS@book> @ ev_namepr 'library cache pin'
==============================
EVENT#                        : 286
EVENT_ID                      : 2802704141
NAME                          : library cache pin
PARAMETER1                    : handle address
PARAMETER2                    : pin address
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PARAMETER3                    : 100*mode+namespace
WAIT_CLASS_ID                 : 3875070507
WAIT_CLASS#                   : 4
WAIT_CLASS                    : Concurrency
PL/SQL procedure successfully completed.

--//P1=000000007C468FC8对应句柄地址.
$ ./ext_kglobz.sh 000000007C468FC8 '' 1a8
0x7c469170:      "LCPSCOTT\210覭|"

SYS@book> select * from x$kglpn where KGLpnadr='000000007C13B4D0';
ADDR                   INDX    INST_ID KGLPNADR         KGLPNUSE         KGLPNSES           KGLPNSID KGLPNHDL         KGLPNLCK           KGLPNCNT   KGLPNMOD   KGLPNREQ   KGLPNFLG   KGLPNDMK   KGLPNSPN   KGLNAHSH
---------------- ---------- ---------- ---------------- ---------------- ---------------- ---------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
00007FAF5A01ED08          2          1 000000007C13B4D0 0000000085D109F8 0000000085D109F8         53 000000007C468FC8 00                        0          0          3       4096          0       1077 3309827384
--//奇怪,oracle这个x表竟然没有类似x$kgllk.KGLNAOBJ字段.

SYS@book> @ sharepool/shp4 '' 3309827384
HANDLE_TYPE            KGLHDADR         KGLHDPAR         C40                                        KGLHDLMD   KGLHDPMD   KGLHDIVC KGLOBHD0         KGLOBHD6           KGLOBHS0   KGLOBHS6   KGLOBT16   N0_6_16        N20   KGLNAHSH KGLOBT03        KGLOBT09
---------------------- ---------------- ---------------- ---------------------------------------- ---------- ---------- ---------- ---------------- ---------------- ---------- ---------- ---------- --------- ---------- ---------- ------------- ----------
parent handle address  000000007C468FC8 000000007C468FC8 LCP.SCOTT                                         3          2          0 000000007BF0ED90 00                     4688          0          0      4688      16976 3309827384                        0
--//一样可以定位对象是LCP.SCOTT.

3.继续:
--//如果在打开一个会话执行编译,出现library cache lock:
--//session 3:
SCOTT@book> @ spid
==============================
SID                           : 138
SERIAL#                       : 9
PROCESS                       : 20610
SERVER                        : DEDICATED
SPID                          : 20611
PID                           : 32
P_SERIAL#                     : 5
KILL_COMMAND                  : alter system kill session '138,9' immediate;
PL/SQL procedure successfully completed.

--//window 3:
$ rlgdb -f -p 20611 -x lkpn11g.gdb

--//session 3:
alter procedure lcp compile;

--//window 3,按c继续:
...
kglGetS0 return lock address : 000000007c1da1e0 000000007c1da1e0
kgllkal count 24 -- handle address: 000000007c08b128, mode: 1 kglnaobj address:0x7c08b2d0:       ""
kglGetS0 return lock address : 000000007c1da0e0 000000007c1da0e0
kgllkal count 25 -- handle address: 000000007c468fc8, mode: 3 kglnaobj address:0x7c469170:       "LCPSCOTT8括}"
kglGetS0 return lock address : 000000007c1d9fe0 000000007c1d9fe0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--//lock address=000000007c1d9fe0

--//session 4:
SYS@book> @ ashtop event,p1raw,p2raw,p3raw 1=1 &min
    Total                                                                                                                                                            Distinct Distinct    Distinct
  Seconds     AAS %This   EVENT                                      P1RAW             P2RAW             P3RAW             FIRST_SEEN          LAST_SEEN           Execs Seen  Tstamps Execs Seen1
--------- ------- ------- ------------------------------------------ ----------------- ----------------- ----------------- ------------------- ------------------- ---------- -------- -----------
       60     1.0   50% | library cache lock                         000000007C468FC8  000000007C1D9FE0  0001759800010003  2024-11-08 10:42:01 2024-11-08 10:43:00          1       60           1
       60     1.0   50% | library cache pin                          000000007C468FC8  000000007C13B4D0  0001759800010003  2024-11-08 10:42:01 2024-11-08 10:43:00          1       60           1
        1      .0    1% |                                                                                                  2024-11-08 10:42:30 2024-11-08 10:42:30          1        1           1
--//EVENT=library cache lock,P1都是一样,P2=000000007C1D9FE0,与前面gdb的跟踪一致.
--//顺便解析P3,PARAMETER3 : 100*mode+namespace
--//拆解几个部分 00017598 0001 0003 ,第2部分是namespace ,第3部分mode,注意intel系列cpu的大小头问题.
--//前面第一部分实际上lcp对象的object_id.

SYS@book> @ o2 scott.lcp
owner                     object_name                    object_type          SEG_PART_NAME        status           OID      D_OID CREATED             LAST_DDL_TIME
------------------------- ------------------------------ -------------------- -------------------- --------- ---------- ---------- ------------------- -------------------
SCOTT                     LCP                            PROCEDURE                                 VALID          95640            2024-11-08 10:25:26 2024-11-08 10:25:26

--//95640 = 0x17598,正好对应对象的Object_id.如果阻塞是sql语句,这部分不存在的.

4.整理后gdb代码如下:
--//注意:每个测试环境不同,调用kglGetSO的返回地址会发生变化的,你必须根据自己的测试环境修改代码。
--//我不知道如何写脚本实现调用kglGetSO返回时,获取寄存器值。

$ cat lkpn11g.gdb2
set pagination off
set print repeats 0
set print elements 0
set logging file /tmp/lkpn.log
set logging overwrite on
set logging on
set $lk  = 0
set $pn  = 0
set $lock  = 0

#break kgllkal if $rdx==3
#break kgllkal if ( $rdx==3 && $rsi==0x00000000670C9E58 )
#break kgllkal if $rsi==0x00000000670C9E58
break kgllkal
commands
 silent
 printf "kgllkal count %02d -- handle address: %016x, mode: %d ", ++$lk ,$rsi ,$rdx
 echo kglnaobj address:
 x/s $rsi+0x1a8
 c
 end

#break kglpnal if $rcx==3
break kglpnal
commands
 silent
 printf "kglpnal count %02d -- handle address: %016x, mode: %d ", ++$pn ,$rsi ,$rdx
 echo kglnaobj address:
 x/s $rsi+0x1a8
 c
 end

#break kglGetSO
#commands
# silent
# finish
# end

break *0x000000000983db73
commands
silent
printf "kglGetS0 return lock address : %016x %016x\n", $rax,$rdx
c
end

break *0x000000000983a048
commands
 silent
 printf "kglGetS0 return pin address : %016x %016x\n", $rax,$rdx
 c
end

标签:11g,--,lock,cache,library,address,----------
From: https://www.cnblogs.com/lfree/p/18535915

相关文章

  • [20241108]跟踪library cache lock library cache pin使用gdb(11g)3.txt
    [20241108]跟踪librarycachelocklibrarycachepin使用gdb(11g)3.txt--//前一段时间写的使用gdb跟踪librarycachelock/librarycachepin的脚本。--//我看过以前的笔记,当时测试过链接https://nenadnoveljic.com/blog/library-cache-lock-debugger/,我的测试在11g是失败.--//......
  • [20241107]nocache的编译.txt
    [20241107]nocache的编译.txt--//原来的测试环境不存在,需要建立nocache工具了解文件缓存情况,学习OS相关知识。--//实际上linux对这些工具从应用角度讲不重要,如果有用,linux实用程序里面应该包含类似工具。可惜一直不提供。--//一般这类安装,我都会写安装笔记,我看了以前的安装笔记,重......
  • zlibrary镜像网址入口,Zlibray最新官方客户端
    Z-Library(也被称为Z-Lib)是一个在线的、开源的、免费的数字图书馆项目,旨在提供各种书籍、文章、科学论文、杂志、漫画等资源的访问。该项目成立于2009年,至今已经收录了超过10,000,000册书籍和80,000,000篇文章。zlibrary电脑客户端/安卓appzlibrary(windows/mac/安卓/ipad)安装包......
  • Oracle10g / oracle11g 安装过程中的常见错误解决办法-【20241118】
    一、oracle10g安装1、在ORACLE10g安装准备的过程中:缺少libXp.so.6依赖上网搜过不少文章,但是都不是很好的解决我自己摸索出一个解决方法:在RHEL5的安装盘中找到libXp-1.0.0-8.i386.rpm,进行安装后,便可解决。2、在ORACLE10g安装过程中Xlib:connectionto......
  • Z-Library入口网站/最新官方国内可用地址(2024持续更新)
    Z-Library,作为全球最大的数字图书馆之一,提供了一个丰富的知识资源库,包括大量的电子书和学术文章。以下是对Z-Library的详细介绍和一些实用的信息。Z-Library数字图书馆简介藏书量:Z-Library拥有超过9,826,996本电子书和84,837,646篇期刊文章,覆盖了从文学、理工学科到人文艺术......
  • oracle11g 常用基本参数优化设置
    1、进程及会话数进程默认150,会话默认是247;查看进程及会话数showparameterprocess;showparametersessions;2、修改进程及会话数altersystemsetprocesses=1250scope=spfile;altersystemsetsessions=1380scope=spfile;SQL>altersystemsetprocesses=1250......
  • Centos7.8静默安装企业版Oracle11g和创建实例
    1、安装环境准备:A、系统版本和oracle11g企业版安装软件压缩包:[root@dbprimary07~]#cat/etc/redhat-releaseCentOSLinuxrelease7.8.2003(Core)[root@dbprimary07~]#uname-aLinuxdbprimary073.10.0-1127.el7.x86_64#1SMPTueMar3123:36:51UTC2020x86_64x......
  • oracle11g启动过程中加载配置文件
    oracle指定配置文件启动,要是不指定配置文件启动的话默认找的参数文件顺序如下:在oracle11g中oracle启动过程中默认会加载相应的配置文件来启动oracle服务。检查参数文件有两个,一个是spfile<ORACLE_SID>.ora文件,另一个是inti<ORACLE_SID>.ora文件。oracle软件服务安装完成后......
  • [20241105]跟踪library cache lock library cache pin使用gdb(11g)2.txt
    [20241105]跟踪librarycachelocklibrarycachepin使用gdb(11g)2.txt--//前一段时间写的使用gdb跟踪librarycachelock/librarycachepin的脚本。--//我看过以前的笔记,当时测试过链接https://nenadnoveljic.com/blog/library-cache-lock-debugger/,我的测试在11g是失败.--//......
  • 通俗易懂的KVcache图解
    在分享之前先提出三个问题:1.为什么KVCache不保存Q2.KVCache如何减少计算量3.为什么模型回答的长度不会影响回答速度?本文将带着这3个问题来详解KVcacheKVcache是什么kvcache是指一种用于提升大模型推理性能的技术,通过缓存注意力机制中的键值(Key-Value)对来减少冗余......