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

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

时间:2024-11-06 20:24:25浏览次数:1  
标签:count 11g handle -- cache library mode address kglnaobj

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

--//前一段时间写的使用gdb跟踪library cache lock/library cache pin的脚本。

--//我看过以前的笔记,当时测试过链接https://nenadnoveljic.com/blog/library-cache-lock-debugger/,我的测试在11g是失败.
--//今天有空再次尝试,确实不成功,不过有了前面测试的经验,可以很容易写成11g的gdb监测脚本.

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

2.测试gdb脚本:
--//我直接给出gdb脚本,一些细节忽略,主要讲解比较麻烦,就是在gdb下设置kgllkal,kglpnal断点.然后使用info register查看寄存器内
--//容,然后获取该执行语句的sql_id,hash_value值,继续退出,然后执行:

@ sharepool/shp4 <sql_id> 0

--//然后查看KGLHDADR的值,对比就知道那个寄存器保存的是对象句柄地址,测试结果对应的寄存器是rsi,至于mode我仅仅猜测是寄存器
--//rdx.这样稍微改改11g的监测脚本就可以写成.
--//里面的偏移量很容易确定,直接opeek 地址 长度 1,看看偏移地址在那里就可以了,11g我的测试结果在0x1a8 = 424.

$ cat lkpn11g.gdb
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

3.测试:
--//session 1:
SCOTT@book> @ spid
==============================
SID                           : 18
SERIAL#                       : 44459
PROCESS                       : 65221
SERVER                        : DEDICATED
SPID                          : 65222
PID                           : 25
P_SERIAL#                     : 96
KILL_COMMAND                  : alter system kill session '18,44459' immediate;
PL/SQL procedure successfully completed.
--//执行desc dept以及Select * from dept where deptno=20;(开头S大小)多次避免递归调用。

--//window 1:
$ rlgdb -f -p  65222 -x lkpn11g.gdb
..
0x000000379a00da70 in __read_nocancel () from /lib64/libpthread.so.0
Breakpoint 1 at 0x983da94
Breakpoint 2 at 0x9839f5c

--//session 1:
SCOTT@book> select * from dept where deptno=12;
no rows selected

--//window 1:
(gdb) c
Continuing.
kgllkal count 01 -- handle address: 000000007bcb6f50, mode: 1 kglnaobj address:0x7bcb70f8:       "select * from dept where deptno=12"
kglpnal count 01 -- handle address: 000000007bcb6f50, mode: 2 kglnaobj address:0x7bcb70f8:       "select * from dept where deptno=12"
kgllkal count 02 -- handle address: 000000007e3371e0, mode: 2 kglnaobj address:0x7e337388:       "bookSYS"
kgllkal count 03 -- handle address: 000000007c19ee50, mode: 2 kglnaobj address:0x7c19eff8:       "2710e6f2 1d05c1f$BUILD$"
--//怎么中间出现1个空格。~~~~~~~~~~~~~
kgllkal count 04 -- handle address: 000000007cb51930, mode: 1 kglnaobj address:0x7cb51ad8:       ""
kglpnal count 02 -- handle address: 000000007cb51930, mode: 3 kglnaobj address:0x7cb51ad8:       ""
kgllkal count 05 -- handle address: 000000007e3371e0, mode: 2 kglnaobj address:0x7e337388:       "bookSYS"
kgllkal count 06 -- handle address: 000000007bcec280, mode: 1 kglnaobj address:0x7bcec428:       "fa4ab910ef98d2aa2710e6f21d05c1fChild:0"
kglpnal count 03 -- handle address: 000000007bcec280, mode: 3 kglnaobj address:0x7bcec428:       "fa4ab910ef98d2aa2710e6f21d05c1fChild:0"
kgllkal count 07 -- handle address: 000000007bcfc0a0, mode: 1 kglnaobj address:0x7bcfc248:       "SCOTT"
kgllkal count 08 -- handle address: 000000007e3371e0, mode: 2 kglnaobj address:0x7e337388:       "bookSYS"
kgllkal count 09 -- handle address: 000000007d2defd0, mode: 2 kglnaobj address:0x7d2df178:       "DEPTSCOTT"
kglpnal count 04 -- handle address: 000000007d2defd0, mode: 2 kglnaobj address:0x7d2df178:       "DEPTSCOTT"
kgllkal count 10 -- handle address: 000000007da13e58, mode: 1 kglnaobj address:0x7da14000:       "\220\021"
kgllkal count 11 -- handle address: 000000007ef0a260, mode: 2 kglnaobj address:0x7ef0a408:       "ICOL$SYS\bz骪177"
kglpnal count 05 -- handle address: 000000007ef0a260, mode: 2 kglnaobj address:0x7ef0a408:       "ICOL$SYS\bz骪177"
--//以上第1次执行,有2个空是子游标句柄,对象内容在父游标句柄里面,有时候取到乱码也是正常的.

kgllkal count 12 -- handle address: 000000007bcb6f50, mode: 1 kglnaobj address:0x7bcb70f8:       "select * from dept where deptno=12"
kgllkal count 13 -- handle address: 000000007cb51930, mode: 1 kglnaobj address:0x7cb51ad8:       ""
kgllkal count 14 -- handle address: 000000007d2defd0, mode: 2 kglnaobj address:0x7d2df178:       "DEPTSCOTT"
kglpnal count 06 -- handle address: 000000007d2defd0, mode: 2 kglnaobj address:0x7d2df178:       "DEPTSCOTT"
--//以上第2次执行

kgllkal count 15 -- handle address: 000000007bcb6f50, mode: 1 kglnaobj address:0x7bcb70f8:       "select * from dept where deptno=12"
kgllkal count 16 -- handle address: 000000007cb51930, mode: 1 kglnaobj address:0x7cb51ad8:       ""
--//以上第3次执行

--//以上第4次执行,没有任何输出,光标已经cache.
SYS@book> @ sharepool/shp4 2f476y80x0r0z 0
HANDLE_TYPE            KGLHDADR         KGLHDPAR         C40                                        KGLHDLMD   KGLHDPMD   KGLHDIVC KGLOBHD0         KGLOBHD6           KGLOBHS0   KGLOBHS6   KGLOBT16   N0_6_16        N20   KGLNAHSH KGLOBT03        KGLOBT09
---------------------- ---------------- ---------------- ---------------------------------------- ---------- ---------- ---------- ---------------- ---------------- ---------- ---------- ---------- --------- ---------- ---------- ------------- ----------
child handle address   000000007CB51930 000000007BCB6F50 select * from dept where deptno=12                0          0          0 000000007CA23A58 000000007C8693C0       4528      12144       3067     19739      19739   30432287 2f476y80x0r0z          0
parent handle address  000000007BCB6F50 000000007BCB6F50 select * from dept where deptno=12                0          0          0 000000007CB39AD0 00                     4720          0          0      4720       4720   30432287 2f476y80x0r0z      65535

--//下划线的对象有一点点奇怪中间有空格.
SYS@book> @ sharepool/shp4z 000000007c19ee50 0
HANDLE_TYPE            KGLHDADR         KGLHDPAR         C40                                        KGLHDLMD   KGLHDPMD   KGLHDIVC KGLOBHD0         KGLOBHD6           KGLOBHS0   KGLOBHS6   KGLOBT16   N0_6_16        N20   KGLNAHSH KGLOBT03        KGLOBT09
---------------------- ---------------- ---------------- ---------------------------------------- ---------- ---------- ---------- ---------------- ---------------- ---------- ---------- ---------- --------- ---------- ---------- ------------- ----------
parent handle address  000000007C19EE50 000000007C19EE50 $BUILD$.2710e6f2 1d05c1f                          0          0          0 00               00                        0          0          0         0          0  438406682                        0
--//hash_value=438406682

SYS@book> select * from v$db_object_cache where hash_value=438406682
  2   @pr
==============================
OWNER                         : $BUILD$
NAME                          : 2710e6f2 1d05c1f
DB_LINK                       :
NAMESPACE                     : SQL AREA BUILD
TYPE                          : CURSOR
SHARABLE_MEM                  : 0
LOADS                         : 0
EXECUTIONS                    : 0
LOCKS                         : 0
PINS                          : 0
KEPT                          : NO
CHILD_LATCH                   : 101914
INVALIDATIONS                 : 0
HASH_VALUE                    : 438406682
LOCK_MODE                     : NONE
PIN_MODE                      : NONE
STATUS                        : UNKOWN
TIMESTAMP                     :
PREVIOUS_TIMESTAMP            :
LOCKED_TOTAL                  : 1
PINNED_TOTAL                  : 0
PROPERTY                      :
FULL_HASH_VALUE               : 6837047da7fa359a5549f81b1a218e1a
PL/SQL procedure successfully completed.
--//才发现11g下v$db_object_cache视图显示的字段太少。

SYS@book> select name,dump(name ,16) c70 from v$db_object_cache where hash_value=438406682;
NAME                                     C70
---------------------------------------- ----------------------------------------------------------------------
2710e6f2 1d05c1f                         Typ=1 Len=16: 32,37,31,30,65,36,66,32,20,31,64,30,35,63,31,66
--//确实有1个空格.0x20.

$ sql_idz.sh "select * from dept where deptno=12\0" 3
sql_text = select * from dept where deptno=12\0
full_hash_value(16) = FA4AB910EF98D2AA2710E6F201D05C1F
xxxxx_matching_signature(10) = 2815003694193466399 or  21261747767903018015
hash_value(10) = 30432287 or hash_value(16) = 01D05C1F
sql_id(32) = 2f476y80x0r0z
sql_id(32) = 2f476y80x0r0z
sql_id(32) = 2f476y80x0r0z

--//对象2710e6f2 1d05c1f$BUILD$的来源是sql语句的FULL_HASH_VALUE的16进制的后16位2710E6F201D05C1F,分开2部分是
--//2710E6F2,01D05C1F,oracle设计有点奇葩,01D05C1F前面的0变成空格吗?看看FULL_HASH_VALUE计算是否正确.

--//kgllkal count 06 -- handle address: 000000007bcec280, mode: 1 kglnaobj address:0x7bcec428:       "fa4ab910ef98d2aa2710e6f21d05c1fChild:0"
--//full_hash_value(16) = FA4AB910EF98D2AA2710E6F201D05C1F
fa4ab910ef98d2aa2710e6f21d05c1f
fa4ab910ef98d2aa2710e6f201d05c1f
--//对象fa4ab910ef98d2aa2710e6f21d05c1fChild:0 也是丢失0.

SYS@book> @ nmsp 'SQL AREA BUILD' -1
@ nmsp table -1
@ nmsp '' 74  or @ nmsp '' 0x4a|x4a
KGLSTDSC                                                           KGLSTIDN KGLSTIDN_HEX
---------------------------------------------------------------- ---------- ------------
SQL AREA BUILD                                                           82 52
--//命名空间82,16进制0x52.

$ sql_idz.sh '2710e6f2 1d05c1f.$BUILD$\x52\0\0\0' 3
sql_text = 2710e6f2 1d05c1f.$BUILD$\x52\0\0\0
full_hash_value(16) = 6837047DA7FA359A5549F81B1A218E1A
xxxxx_matching_signature(10) = 6145715961809964570 or  24592460035519516186
hash_value(10) = 438406682 or hash_value(16) = 1A218E1A
sql_id(32) = 5akgs3cd233hu
sql_id(32) = 5akgs3cd233hu
sql_id(32) = 5akgs3cd233hu
--//确实使用空格计算的.full_hash_value(16) = 6837047DA7FA359A5549F81B1A218E1A与前面的使用如下语句的查询结果一致。
--//select * from v$db_object_cache where hash_value=438406682

kgllkal count 73 -- handle address: 000000007be33760, mode: 1 kglnaobj address:0x7be33908:       "select * from dept where deptno=15"
kglpnal count 29 -- handle address: 000000007be33760, mode: 2 kglnaobj address:0x7be33908:       "select * from dept where deptno=15"
kgllkal count 74 -- handle address: 000000007e3371e0, mode: 2 kglnaobj address:0x7e337388:       "bookSYS"
kgllkal count 75 -- handle address: 000000007cab2918, mode: 2 kglnaobj address:0x7cab2ac0:       " c3ba9c9ee26d7a6$BUILD$"   --//空格再次出现。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kgllkal count 76 -- handle address: 000000007db6e0d0, mode: 1 kglnaobj address:0x7db6e278:       "\220\021" -//乱码
kglpnal count 30 -- handle address: 000000007db6e0d0, mode: 3 kglnaobj address:0x7db6e278:       "\220\021"
kgllkal count 77 -- handle address: 000000007e3371e0, mode: 2 kglnaobj address:0x7e337388:       "bookSYS"
kgllkal count 78 -- handle address: 000000007c9cd2c8, mode: 1 kglnaobj address:0x7c9cd470:       "f2afd967b55d9efac3ba9c9ee26d7a6Child:0"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kglpnal count 31 -- handle address: 000000007c9cd2c8, mode: 3 kglnaobj address:0x7c9cd470:       "f2afd967b55d9efac3ba9c9ee26d7a6Child:0"
kgllkal count 79 -- handle address: 000000007bcfc0a0, mode: 1 kglnaobj address:0x7bcfc248:       "SCOTT"
kgllkal count 80 -- handle address: 000000007e3371e0, mode: 2 kglnaobj address:0x7e337388:       "bookSYS"
kgllkal count 81 -- handle address: 000000007d2defd0, mode: 2 kglnaobj address:0x7d2df178:       "DEPTSCOTT"
kglpnal count 32 -- handle address: 000000007d2defd0, mode: 2 kglnaobj address:0x7d2df178:       "DEPTSCOTT"

$ sql_idz.sh "select * from dept where deptno=15\0" 3
sql_text = select * from dept where deptno=15\0
full_hash_value(16) = F2AFD967B55D9EFA0C3BA9C9EE26D7A6
xxxxx_matching_signature(10) = 881484836830107558 or  19328228910539659174
hash_value(10) = 3995522982 or hash_value(16) = EE26D7A6
sql_id(32) = 0sfx9t7r2dpx6
sql_id(32) =  sfx9t7r2dpx6
sql_id(32) =  sfx9t7r2dpx6
--//视乎11g下有一些不能理解的地方,开头的0变成空格.
--//f2afd967b55d9efac3ba9c9ee26d7a6 长度31也去掉0.
--//F2AFD967B55D9EFA0C3BA9C9EE26D7A6 长度32.
--//这里的0是字符'0',不是chr(0),oracle 11g为什么要这样设计变成空格呢?不理解。

标签:count,11g,handle,--,cache,library,mode,address,kglnaobj
From: https://www.cnblogs.com/lfree/p/18530945

相关文章

  • 通俗易懂的KVcache图解
    在分享之前先提出三个问题:1.为什么KVCache不保存Q2.KVCache如何减少计算量3.为什么模型回答的长度不会影响回答速度?本文将带着这3个问题来详解KVcacheKVcache是什么kvcache是指一种用于提升大模型推理性能的技术,通过缓存注意力机制中的键值(Key-Value)对来减少冗余......
  • zlibrary中文版入口及电子书客户端/app(2024更新)
    Z-library是一个全球范围内庞大的数字图书馆之一,其藏书量非常丰富。截至最新数据,Z-library共收录了超过9,826,996册电子书以及84,837,646篇学术期刊文章。这个数字图书馆覆盖了从经典文学巨著到前沿理工学科,从人文艺术瑰宝到专业学术论文的广泛领域,几乎能够满足每一位求知者的阅读......
  • Linux基础——服务器Raid阵列卡开启cache缓存
    服务器Raid阵列卡开启cache缓存一、问题描述客户业务环境:本地存储型裸金属服务器做NFS服务器,15台以上的客户端接入服务器,读写大量的小文件,客户读写速录慢的现象;影响读写速率:磁盘性能和磁盘缓存,容易造成大量的IO拥塞;二、问题分析裸金属NFS服务器单盘最大IOPS2200,一台主机可能......
  • ossfs 禁用cache配置说明
    ossfs基于osssdk实现了与ossfs类似的能了,但是默认是有cache的,尤其我们的longrunning任务可能会影响,造成获取的数据是不是最新的,解决方法就是直接禁用cache参考处理#通过临时调整cache有效期解决fromossfsimportOSSFileSystemfs=ossfs.OSSFileSystem(li......
  • 后羿 - TenSunS v1.1.0 支持对接AWS的EC2、RDS、ElastiCache
    ......
  • library官网中文版,zlibrary网页版如何下载书籍
    zlibrary数字图书馆介绍Z-library被称为全球最大的数字图书馆,里面包含9,826,996本电子书,84,837,646篇期刊文章。从各种知名文学著作,理工学科,人文艺术、到学术论文等应有尽有!支持PDF、epub、mobi等多种格式图书资源下载绝对是你找书的不二选择。library官网中文版zlibrary......
  • 24小时搜书官网及zlibrary中文网址/客户端app
    24小时搜书(24hBookstore):一个免费电子书下载网站,支持通过书名、作者、出版社和ISBN编号等方式搜索和下载电子书。网站操作简单,直接下载无需多余步骤,支持azw3、mobi、epub、pdf等多种格式筛选。无论是通过书名、作者、出版社还是ISBN编号进行搜索。以下是一些使用这个网站的要点......
  • 24小时搜书网站及zlibrary中文镜像网站/客户端app(更新中)
    24小时搜书网站是一个基于IPFS的电子书搜索引擎,它提供了丰富的电子书资源,覆盖文学、心理、艺术、设计、小说等多个领域。以下是该网站的一些主要特点:资源丰富:24小时搜书网站收录了超过12.7万本图书,支持通过书名、作者、出版社、ISBN编号等多种方式进行搜索。多种格式下载:用户可......
  • 深入解析 Memcached原理、架构与最佳实践
    1.引言什么是Memcached?Memcached是一个高性能的分布式内存对象缓存系统,旨在通过减少数据库负载来加速动态Web应用程序。它以键值对的形式将数据存储在内存中,允许应用程序快速读取数据,从而提高响应速度和系统的可扩展性。由于其简单的设计和高效的性能,Memcached被广......
  • 24小时搜书store及Z-library镜像地址/客户端/app
    24小时搜书是一个提供电子书搜索和下载服务的平台,它允许用户通过互联网搜索和获取电子书资源。以下是一些可能的特点和功能:搜索功能:用户可以通过书名、作者、ISBN号等关键词来搜索想要的电子书。资源丰富:平台可能包含多种语言和类型的电子书,覆盖小说、教育、科技等多个领域。多......