首页 > 其他分享 >[20241124]测试软软解析人为修改cursor pin S的mutext值.txt

[20241124]测试软软解析人为修改cursor pin S的mutext值.txt

时间:2024-11-24 21:23:22浏览次数:3  
标签:mutext 06 pin ru 0x1 16 getrusage txt select

[20241124]测试软软解析人为修改cursor pin S的mutext值.txt

--//测试软软解析人为修改cursor pin S的mutext值会出现怎么情况。

1.环境:
SCOTT@book01p> @ver2
==============================
PORT_STRING                   : x86_64/Linux 2.4.xx
VERSION                       : 21.0.0.0.0
BANNER                        : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
BANNER_FULL                   : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
BANNER_LEGACY                 : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
CON_ID                        : 0
PL/SQL procedure successfully completed.

2.建立测试环境:
create table job_times (sid number, time_ela number,method varchar2(20));

drop table t purge ;
create table t as select rownum id ,'test' pad from dual connect by level<=5e5;
create unique index pk_t on t(id);
exec dbms_stats.gather_table_stats(user, 't', method_opt=>'for all columns size 1');

$ cat m9.txt
set verify off
variable v_method varchar2(20)
exec :v_method := '&&2';

insert into job_times values ( sys_context ('userenv', 'sid') ,dbms_utility.get_time ,:v_method) ;
commit ;

DECLARE
   l_count PLS_INTEGER;
BEGIN
    FOR i IN 1..&&1
    LOOP
       EXECUTE IMMEDIATE 'Select /*+ &2 */ count(*) from t where id = :j ' INTO l_count USING i;
    END LOOP;
END;
/

update job_times set time_ela = dbms_utility.get_time - time_ela where sid=sys_context ('userenv', 'sid') and method= :v_method;
commit;
quit

3.测试:
--//delete from JOB_TIMES ;
--//commit ;
--//删除前面的测试结果。

$ zzdate;seq 20 | xargs -P 20 -IQ sqlplus -s -l scott/book@book01p @m9.txt 1e4 AAAA > /dev/null;zzdate
trunc(sysdate)+15/24+42/1440+00/86400
trunc(sysdate)+15/24+42/1440+03/86400

SYS@book> @ mutexprofz idn,hash,loc,maddr "ts>=trunc(sysdate)+15/24+42/1440+00/86400 and ts<=trunc(sysdate)+15/24+42/1440+03/86400"
-- MutexProf by Tanel Poder (http://www.tanelpoder.com)
-- Showing profile of top 20 sleeps...
-- column info : id idn hash hash_value=>hash_value ts=>sleep_timestamp
--               req=>requesting_session blk=>blocking_session val=>mutex_value maddr=>mutex_addr

SUM_SLEEPS      GETS_DIFF MUTEX_TYPE             IDN       HASH GET_LOCATION                      mutex_addr           OBJECT_NAME
---------- -------------- --------------- ---------- ---------- --------------------------------- -------------------- --------------------------------------------------------------------------------
        25         258891 Cursor Pin       321664448  321664448 kksLockDelete [KKSCHLPIN6]        00000000611FCD58     Select /*+ AAAA */ count(*) from t where id = :j
         3         123257 Cursor Pin       321664448  321664448 kksfbc [KKSCHLFSP2]               00000000611FCD58     Select /*+ AAAA */ count(*) from t where id = :j
--//主要目的获得mutex_addr=00000000611FCD58。

SYS@book> @ opeek 00000000611FCD58 24 1
New tracefile_identifier = /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_3440_0001.trc
[0611FCD58, 0611FCD70) = 00000000 00000000 00061A98 000000C1 132C35C0 00000000

--//前面8位是mutex的值。前4位为持有mutex的数量,后4位为阻塞的sid,注意ashtop输出p2raw参数大小头问题显示是反过来的。

$ mod_addr.sh 00000000611FCD58 0 100
0x611fcd58:     0x00000100

SYS@book> @ opeek 00000000611FCD58 24 1
New tracefile_identifier = /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_3440_0002.trc
[0611FCD58, 0611FCD70) = 00000100 00000000 00061A99 000000C1 132C35C0 00000000

--//session 1:
SCOTT@book01p> @ spid
==============================
SID                           : 145
SERIAL#                       : 5816
PROCESS                       : 4007
SERVER                        : DEDICATED
SPID                          : 4009
PID                           : 45
P_SERIAL#                     : 7
KILL_COMMAND                  : alter system kill session '145,5816' immediate;
PL/SQL procedure successfully completed.

--//window 1:
$ strace -f -p 4009  -y -Ttt 2>&1 | tee /tmp/test.txt

--//session 1:
SCOTT@book01p> @ m9.txt 1 AAAA
PL/SQL procedure successfully completed.
1 row created.
Commit complete.
PL/SQL procedure successfully completed.
1 row updated.
Commit complete.

4.测试2:
--//修改后4位。
$ mod_addr.sh 00000000611FCD58 4 1
0x611fcd5c:     0x00000001

SYS@book> @ opeek 00000000611FCD58 24 1
New tracefile_identifier = /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_3440_0003.trc
[0611FCD58, 0611FCD70) = 00000000 00000001 00061AAD 00004CA5 132C35C0 00000000

--//window 1:
$ strace -f -p 4557  -y -Ttt 2>&1 | tee /tmp/test2.txt

--//session 1:
SCOTT@book01p> @ m9.txt 1 AAAA

--//挂起!!

SYS@book> @ ashtop event,p1raw,p1,p2raw 1=1 trunc(sysdate)+16/24+04/1440+18/86400 sysdate
    Total                                                                                                                                                     Distinct Distinct    Distinct
  Seconds     AAS %This   EVENT                                      P1RAW                     P1 P2RAW             FIRST_SEEN          LAST_SEEN           Execs Seen  Tstamps Execs Seen1
--------- ------- ------- ------------------------------------------ ----------------- ---------- ----------------- ------------------- ------------------- ---------- -------- -----------
       18      .1   43% | cursor: pin S                              00000000132C35C0   321664448 0000000100000000  2024-11-24 16:06:29 2024-11-24 16:06:46          1       18          18
       12      .1   29% |                                                                     100                   2024-11-24 16:04:36 2024-11-24 16:07:12          1       11          11
        9      .0   21% |                                                                       3                   2024-11-24 16:04:36 2024-11-24 16:05:56          1        9           9
        2      .0    5% |                                                                       1                   2024-11-24 16:05:04 2024-11-24 16:05:25          1        2           2
        1      .0    2% |                                                                       0                   2024-11-24 16:05:58 2024-11-24 16:05:58          1        1           1

SYS@book> @ mutexprofz idn,hash,loc,maddr "ts>=trunc(sysdate)+16/24+04/1440+18/86400 and maddr='00000000611FCD58'"
-- MutexProf by Tanel Poder (http://www.tanelpoder.com)
-- Showing profile of top 20 sleeps...
-- column info : id idn hash hash_value=>hash_value ts=>sleep_timestamp
--               req=>requesting_session blk=>blocking_session val=>mutex_value maddr=>mutex_addr

SUM_SLEEPS      GETS_DIFF MUTEX_TYPE             IDN       HASH GET_LOCATION                      mutex_addr           OBJECT_NAME
---------- -------------- --------------- ---------- ---------- --------------------------------- -------------------- -------------------------------------------------
      5276                Cursor Pin       321664448  321664448 kkslce [KKSCHLPIN2]               00000000611FCD58     Select /*+ AAAA */ count(*) from t where id = :j

 $ egrep  "sched_yield|getrusage|select" /tmp/test2.txt  | awk '{print $2}'|  uniq -c| head -60
    187 select(0,
      1 getrusage(0x1
    652 select(0,
      1 getrusage(0x1
    400 select(0,
      1 getrusage(0x1
    754 select(0,
      1 getrusage(0x1
    321 select(0,
      1 getrusage(0x1
    486 select(0,
      1 getrusage(0x1
    528 select(0,
      1 getrusage(0x1
    963 select(0,
      1 getrusage(0x1
    290 select(0,
      9 getrusage(0x1

$ egrep  "sched_yield|getrusage|select" /tmp/test2.txt  | grep getrusage
16:06:32.546801 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 57279}, ru_stime={0, 31503}, ...}) = 0 <0.000013>
16:06:34.553095 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 73031}, ru_stime={0, 50457}, ...}) = 0 <0.000022>
16:06:36.558399 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 79758}, ru_stime={0, 61748}, ...}) = 0 <0.000018>
16:06:38.561963 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 109984}, ru_stime={0, 77131}, ...}) = 0 <0.000054>
16:06:40.563244 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 123649}, ru_stime={0, 81969}, ...}) = 0 <0.000009>
16:06:42.573588 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 134842}, ru_stime={0, 95343}, ...}) = 0 <0.000013>
16:06:44.577038 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 153945}, ru_stime={0, 108586}, ...}) = 0 <0.000047>
16:06:46.578335 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 172698}, ru_stime={0, 127025}, ...}) = 0 <0.000054>
16:06:46.970193 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 178005}, ru_stime={0, 129856}, ...}) = 0 <0.000013>
16:06:46.971183 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 178220}, ru_stime={0, 130013}, ...}) = 0 <0.000012>
16:06:46.971384 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 178315}, ru_stime={0, 130082}, ...}) = 0 <0.000042>
16:06:46.971767 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 178492}, ru_stime={0, 130211}, ...}) = 0 <0.000023>
16:06:46.972097 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 178530}, ru_stime={0, 130239}, ...}) = 0 <0.000012>
16:06:46.972316 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 178609}, ru_stime={0, 130297}, ...}) = 0 <0.000011>
16:06:46.973629 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 179287}, ru_stime={0, 130297}, ...}) = 0 <0.000017>
16:06:46.977169 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 179287}, ru_stime={0, 130297}, ...}) = 0 <0.000011>
16:06:46.978066 getrusage(0x1 /* RUSAGE_??? */, {ru_utime={0, 179750}, ru_stime={0, 130297}, ...}) = 0 <0.000031>
--//调用getrusage 2秒间隔。

$ egrep  "sched_yield|getrusage|select" /tmp/test2.txt  | grep select | head -10
16:06:31.865221 select(0, [], [], [], {0, 167}) = 0 (Timeout) <0.001087>
16:06:31.866541 select(0, [], [], [], {0, 1000}) = 0 (Timeout) <0.001832>
16:06:31.868463 select(0, [], [], [], {0, 1000}) = 0 (Timeout) <0.001889>
16:06:31.870420 select(0, [], [], [], {0, 1000}) = 0 (Timeout) <0.001885>
16:06:31.872362 select(0, [], [], [], {0, 1000}) = 0 (Timeout) <0.001827>
16:06:31.874246 select(0, [], [], [], {0, 1000}) = 0 (Timeout) <0.001098>
16:06:31.875419 select(0, [], [], [], {0, 1000}) = 0 (Timeout) <0.001811>
16:06:31.877299 select(0, [], [], [], {0, 1000}) = 0 (Timeout) <0.002742>
16:06:31.880132 select(0, [], [], [], {0, 1000}) = 0 (Timeout) <0.002035>
16:06:31.882230 select(0, [], [], [], {0, 1000}) = 0 (Timeout) <0.001717>
--//休眠的时间是1毫秒。

5.mod_addr.sh 代码如下:

$ cat mod_addr.sh
#/bin/bash
# modify address value
# arg1=address arg2=offset (default 0) arg3=value (default 0)

offset=${2:-0}
value=${3:-0}
gdb -q -batch -p $(pgrep -f ora_mmon_${ORACLE_SID}) -ex "set *(  int *)(0x${1}+0x${offset})=0x${value}"  -ex "x /wx 0x${1}+0x${offset}"  -ex "quit" |  grep "^0x" | grep -v "^0x0"

标签:mutext,06,pin,ru,0x1,16,getrusage,txt,select
From: https://www.cnblogs.com/lfree/p/18566389

相关文章

  • [20241121]测试软软解析遇到的疑惑.txt
    [20241121]测试软软解析遇到的疑惑.txt--//测试软软解析遇到的疑惑,就是大量软软解析以及分散执行两者的执行时间差别并不是很大,有点疑惑,展开分析看看。1.环境:SCOTT@book01p>@ver2==============================PORT_STRING                  :x86_64/Linux......
  • [20241123]11g下测试遇到latch shared pool等待事件问题.txt
    [20241123]11g下测试遇到latchsharedpool等待事件问题.txt--//这是昨天测试遇到的问题,实际上以前也遇到,没有仔细探究。以前的方法就是启动后做小量延迟,规避这个问题,实际上还是出现。--//这次测试我总感觉哪里做的不对,仔细分析看看。1.环境:SCOTT@book>@ver1PORT_STRING    ......
  • pinia基本知识整理
    看了B站up小满zs的pinia视频,整理的笔记如下了解piniapinia的组成就是state,getters,actions三个部分。下面是完整使用实例化一个pinia使用的时候,在组件里面引入路由import{useTestStore}from'./store'constTest=useTestStore()main.js首先需要再全局引入pinia......
  • import torch 报错 ModuleNotFoundError: No module named ‘typing_extensions’
    确认报错位置,报错文件上一级为torch:File"/home/jy/anaconda3/envs/py37_NLD/lib/python3.7/site-packages/torch/serialization.py",line18下载typing_extensions.py文件包:链接:https://pan.quark.cn/s/1db47c56369c提取码:XJkM将typing_extensions.py文件移动......
  • 海康威视AI开放平台训练数据集导入问题---解决导入自己数据集的问题(txt转json格式)
    一、问题导入首先我们先进入到开放平台中,选择物体检测最近在做一个项目,需要使用到海康威视AI开放平台来训练数据集,但是刚开始遇到了一个问题就是导入自己的数据集(txt格式转成了json格式)为啥没有用,后面查看相关文档,解决了导入自己数据集的问题,就不用在平台里标注了。二、探......
  • SpingBoot原理
    1.配置优先级配置文件优先级排名(从高到低):1.properties配置文件2.yml配置文件3.yaml配置文件在SpringBoot项目当中除了以上3种配置文件外,SpringBoot为了增强程序的扩展性,除了支持配置文件的配置方式以外,还支持另外两种常见的配置方式:......
  • flume传输数据报错“Space for commit to queue couldn‘t be acquired. Sinks are li
        最近在写一个数据量比较大的项目时候,需要使用flume将kafka中的数据传输到HDFS上进行存储,方便后续的数仓搭建,但是flume在传输数据中却报错如下日志org.apache.flume.ChannelFullException:Spaceforcommittoqueuecouldn'tbeacquired.Sinksarelikelynot......
  • Spingboot 定时任务与过滤器,拦截器
     在boot环境中,一般来说,要实现定时任务,我们有两中方案,一种是使用Spring自带的定时任务处理器@Scheduled注解,另一种就是使用第三方框架Quartz,SpringBoot源自Spring+SpringMVC,因此天然具备这两个Spring中的定时任务实现策略,当然也支持Quartz1.定时任务@Sched......
  • 软件分享|PixPin 截图工具
    Hey朋友们,是不是还在用老旧的截图方式?今天,我要给你们介绍一款截图工具——PixPin,它将彻底改变你的工作方式!(文末附下载地址)......
  • 【deepin23】python 与 julia环境搭建
    基于deepin23操作系统deepin23操作系统自带python3.12软件,但是没有pip程序。可以自行安装pip程序打开终端更新apt库sudoaptupdatesudoaptupgrade安装pip工具sudoaptinstallpython-pippipconfigsetglobal.index-urlhttps://mirrors.ali......