[20190416]完善shared latch測試指令碼2.txt
[20190416]完善shared latch測試指令碼2.txt
--//昨天測試shared latch,連結:http://blog.itpub.net/267265/viewspace-2641414/,感覺有點開竅了.^_^.
For the shared latches Oracle 10g uses kslgetsl(laddr, wait, why, where, mode) function. Oracle 11g has kslgetsl_w()
function with the same interface, but internally uses ksl_get_shared_latch(). Like in my previous post, I guess the
meaning of kslgetsl() arguments as:
--//對於共享鎖存,Oracle 10g使用kslgetsl(laddr,wait,why,where,mode)函式。Oracle 11g具有相同介面的kslgetsl_w()函式,但
--//在內部使用ksl_get_share_latch()。與上一篇文章一樣,我認為kslgetsl()引數的含義是:
--//注:我以前一直以為還是kslgetsl,原來11g已經改為kslgetsl_w,不過內部使用還是ksl_get_shared_latch().
laddress -- address of latch in SGA
wait -- flag. If not 0, then willing-to-wait latch get
why -- context why the latch is acquired at this where.
where -- location from where the latch is acquired (x$ksllw.indx)
And the last one is:
mode – Exclusive or shared mode
the mode argument took only two values:
8 -- "SHARED"
16 -- "EXCLUSIVE"
--//我當時的測試針對'gcs partitioned table hash' latch,完善修改測試指令碼,增加一些通用性.
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 shared_latch.txt
/* 引數如下: @ latch.txt latch_name willing why where mode sleep_num */
connect / as sysdba
col laddr new_value laddr
col vmode new_value vmode
select decode(lower('&&5'),'s',8,'x',16,'8',8,'16',16) vmode from dual ;
SELECT addr laddr FROM v$latch_parent WHERE NAME='&&1';
oradebug setmypid
oradebug call kslgetsl_w 0x&laddr &&2 &&3 &&4 &vmode
host sleep &&6
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)
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;
$ cat /usr/local/bin/timestamp.pl
#!/usr/bin/perl
while (<>) {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
printf("%02d:%02d:%02d", $hour, $min, $sec);
print ": $_";
#print localtime() . ": $_";
}
--//使用timestamp.pl在開始標註時間.這樣更加清晰.
2.測試:
--//補充測試 X mode,S mode ,X 模式的情況.
$ cat f1.sh
#! /bin/bash
source peek.sh 'gcs partitioned table hash' 30 | timestamp.pl >| /tmp/peeks.txt &
seq 30 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >| /tmp/latch_free.txt &
# 引數如下: @ latch.txt latch_name willing why where mode sleep_num
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 4 5 x 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 4 5 s 6 > /dev/null &
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 4 5 s 6 > /dev/null &
sleep 0.1
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 4 5 x 6 > /dev/null &
wait
$ grep -v '^.*: $' /tmp/peeks.txt
09:28:38: SYSDATE LADDR
09:28:38: ------------------- ----------------
09:28:38: 2019-04-16 09:28:38 0000000060018A18
09:28:38: Statement processed.
09:28:38: [060018A18, 060018A20) = 0000001C 20000000
09:28:39: [060018A18, 060018A20) = 0000001C 20000000
09:28:40: [060018A18, 060018A20) = 0000001C 20000000
09:28:41: [060018A18, 060018A20) = 0000001C 20000000
09:28:42: [060018A18, 060018A20) = 0000001C 20000000
09:28:43: [060018A18, 060018A20) = 0000001C 20000000
09:28:44: [060018A18, 060018A20) = 00000001 00000000
09:28:45: [060018A18, 060018A20) = 00000001 00000000
09:28:46: [060018A18, 060018A20) = 00000001 00000000
09:28:47: [060018A18, 060018A20) = 00000001 00000000
09:28:48: [060018A18, 060018A20) = 00000001 00000000
09:28:49: [060018A18, 060018A20) = 00000001 00000000
09:28:50: [060018A18, 060018A20) = 00000001 00000000
09:28:51: [060018A18, 060018A20) = 00000001 00000000
09:28:52: [060018A18, 060018A20) = 00000001 00000000
09:28:53: [060018A18, 060018A20) = 00000001 00000000
09:28:54: [060018A18, 060018A20) = 00000001 00000000
09:28:55: [060018A18, 060018A20) = 00000001 00000000
09:28:56: [060018A18, 060018A20) = 0000001F 20000000
09:28:57: [060018A18, 060018A20) = 0000001F 20000000
09:28:58: [060018A18, 060018A20) = 0000001F 20000000
09:28:59: [060018A18, 060018A20) = 0000001F 20000000
09:29:00: [060018A18, 060018A20) = 0000001F 20000000
09:29:01: [060018A18, 060018A20) = 0000001F 20000000
09:29:02: [060018A18, 060018A20) = 00000000 00000000
09:29:03: [060018A18, 060018A20) = 00000000 00000000
09:29:04: [060018A18, 060018A20) = 00000000 00000000
09:29:05: [060018A18, 060018A20) = 00000000 00000000
09:29:06: [060018A18, 060018A20) = 00000000 00000000
09:29:07: [060018A18, 060018A20) = 00000000 00000000
$ grep -v '^.*: $' /tmp/peeks.txt | cut -c10- | uniq -c
1 SYSDATE LADDR
1 ------------------- ----------------
1 2019-04-16 09:28:38 0000000060018A18
1 Statement processed.
6 [060018A18, 060018A20) = 0000001C 20000000
12 [060018A18, 060018A20) = 00000001 00000000
6 [060018A18, 060018A20) = 0000001F 20000000
6 [060018A18, 060018A20) = 00000000 00000000
--//僅僅注意一個細節,peek值 的後4位並沒有出現0x40000000的情況.
$ cat /tmp/latch_free.txt
2019-04-16 09:28:38
2019-04-16 09:28:39
Process 28
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=58
2019-04-16 09:28:40
Process 28
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=58
Process 29, waiting for: 0000000060018A18 whr=5 why=4
Process 30, waiting for: 0000000060018A18 whr=5 why=4
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:41
Process 28
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=58
Process 29, waiting for: 0000000060018A18 whr=5 why=4
Process 30, waiting for: 0000000060018A18 whr=5 why=4
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:42
Process 28
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=58
Process 29, waiting for: 0000000060018A18 whr=5 why=4
Process 30, waiting for: 0000000060018A18 whr=5 why=4
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:44
Process 28
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=58
Process 29, waiting for: 0000000060018A18 whr=5 why=4
Process 30, waiting for: 0000000060018A18 whr=5 why=4
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:45
Process 29
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=72
Process 30, waiting for: 0000000060018A18 whr=5 why=4
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:46
Process 29
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=72
Process 30, waiting for: 0000000060018A18 whr=5 why=4
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:47
Process 29
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=72
Process 30, waiting for: 0000000060018A18 whr=5 why=4
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:48
Process 29
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=72
Process 30, waiting for: 0000000060018A18 whr=5 why=4
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:49
Process 29
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=72
Process 30, waiting for: 0000000060018A18 whr=5 why=4
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:50
Process 29
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=72
Process 30, waiting for: 0000000060018A18 whr=5 why=4
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:51
Process 30
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=86
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:52
Process 30
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=86
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:53
Process 30
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=86
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:54
Process 30
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=86
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:56
Process 30
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=86
Process 31, waiting for: 0000000060018A18 whr=5 why=4
2019-04-16 09:28:57
Process 31
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=101
2019-04-16 09:28:58
Process 31
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=101
2019-04-16 09:28:59
Process 31
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=101
2019-04-16 09:29:00
Process 31
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=101
2019-04-16 09:29:01
Process 31
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=101
2019-04-16 09:29:02
Process 31
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=101
2019-04-16 09:29:03
2019-04-16 09:29:04
--//結果我就不再講解了.
--//不過有點奇怪的是,如果修改f1.sh如下:
$ cat f1.sh
#! /bin/bash
source peek.sh 'gcs partitioned table hash' 30 | timestamp.pl >| /tmp/peeks.txt &
seq 30 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >| /tmp/latch_free.txt &
# 引數如下: @ latch.txt latch_name willing why where mode sleep_num
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 4 5 x 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 7 8 s 6 > /dev/null &
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 9 10 s 6 > /dev/null &
##sleep 0.1
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 11 12 x 6 > /dev/null &
wait
--//註解sleep 0.01秒.結果如下:
$ grep -v '^.*: $' /tmp/peeks.txt | cut -c10- | uniq -c
1 SYSDATE LADDR
1 ------------------- ----------------
1 2019-04-16 09:33:37 0000000060018A18
1 Statement processed.
6 [060018A18, 060018A20) = 0000001D 20000000
6 [060018A18, 060018A20) = 0000001F 20000000
12 [060018A18, 060018A20) = 00000001 00000000
6 [060018A18, 060018A20) = 00000000 00000000
--//給人的感覺優先處理X mode 鎖,然後才是S mode.我測試多次結果都一樣.如果修改如下:
$ cat f1.sh
#! /bin/bash
source peek.sh 'gcs partitioned table hash' 30 | timestamp.pl >| /tmp/peeks.txt &
seq 30 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >| /tmp/latch_free.txt &
# 引數如下: @ latch.txt latch_name willing why where mode sleep_num
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 4 5 x 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 7 8 s 6 > /dev/null &
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 11 12 x 6 > /dev/null &
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 9 10 s 6 > /dev/null &
##sleep 0.1
wait
$ grep -v '^.*: $' /tmp/peeks.txt | cut -c10- | uniq -c
1 SYSDATE LADDR
1 ------------------- ----------------
1 2019-04-16 09:37:56 0000000060018A18
1 Statement processed.
6 [060018A18, 060018A20) = 0000001B 20000000
6 [060018A18, 060018A20) = 00000001 00000000
6 [060018A18, 060018A20) = 0000001E 20000000
6 [060018A18, 060018A20) = 00000001 00000000
6 [060018A18, 060018A20) = 00000000 00000000
--//僅僅注意一個細節,peek值 的後4位並沒有出現0x40000000的情況.
--//latch_free.txt
2019-04-16 09:37:56
2019-04-16 09:37:57
Process 27
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=44
2019-04-16 09:37:58
Process 27
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=44
Process 29, waiting for: 0000000060018A18 whr=10 why=9
Process 30, waiting for: 0000000060018A18 whr=12 why=11
Process 31, waiting for: 0000000060018A18 whr=8 why=7
--//同時執行的sql語句,總是最後1個先啟動執行.
2019-04-16 09:37:59
Process 27
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=44
Process 29, waiting for: 0000000060018A18 whr=10 why=9
Process 30, waiting for: 0000000060018A18 whr=12 why=11
Process 31, waiting for: 0000000060018A18 whr=8 why=7
2019-04-16 09:38:01
Process 27
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=44
Process 29, waiting for: 0000000060018A18 whr=10 why=9
Process 30, waiting for: 0000000060018A18 whr=12 why=11
Process 31, waiting for: 0000000060018A18 whr=8 why=7
2019-04-16 09:38:02
Process 27
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=5 why=4, SID=44
Process 29, waiting for: 0000000060018A18 whr=10 why=9
Process 30, waiting for: 0000000060018A18 whr=12 why=11
Process 31, waiting for: 0000000060018A18 whr=8 why=7
2019-04-16 09:38:03
Process 29
holding: 0000000060018A18 "gcs partitioned table hash" lvl=6 whr=10 why=9, SID=72
Process 30, waiting for: 0000000060018A18 whr=12 why=11
Process 31, waiting for: 0000000060018A18 whr=8 why=7
--//總之,有了這些指令碼大家可以自行組合測試.我僅僅測試
--//SSS XSS SXS XXX
--//這裡算是XSX,是否後4位出現的規律與第1次持有的mode是shared還是EXCLUSIVE有關.
--//視乎peek看到的值與入隊時當前持有的狀態shared,exclusive有關.
$ cat g1.sh
#! /bin/bash
source peek.sh 'gcs partitioned table hash' 30 | timestamp.pl >| /tmp/peeks.txt &
seq 30 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >| /tmp/latch_free.txt &
# 引數如下: @ latch.txt latch_name willing why where mode sleep_num
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 4 5 s 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 7 8 x 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 9 10 x 6 > /dev/null &
wait
$ grep -v '^.*: $' /tmp/peeks.txt | cut -c10- | uniq -c
1 SYSDATE LADDR
1 ------------------- ----------------
1 2019-04-16 09:48:14 0000000060018A18
1 Statement processed.
2 [060018A18, 060018A20) = 00000001 00000000
4 [060018A18, 060018A20) = 00000001 40000000
6 [060018A18, 060018A20) = 0000001D 20000000
6 [060018A18, 060018A20) = 0000001E 20000000
12 [060018A18, 060018A20) = 00000000 00000000
--//這樣出現後4位是0x40000000好像僅僅一種可能,就是當前持有S mode,入隊X mode時才會出現這樣的情況.
--//再做一個例子:
$ cat g1.sh
#! /bin/bash
source peek.sh 'gcs partitioned table hash' 30 | timestamp.pl >| /tmp/peeks.txt &
seq 30 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >| /tmp/latch_free.txt &
# 引數如下: @ latch.txt latch_name willing why where mode sleep_num
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 4 5 s 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 7 8 s 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 9 10 x 6 > /dev/null &
sleep 1
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 11 12 x 6 > /dev/null &
wait
$ grep -v '^.*: $' /tmp/peeks.txt | cut -c10- | uniq -c
1 SYSDATE LADDR
1 ------------------- ----------------
1 2019-04-16 09:58:45 0000000060018A18
1 Statement processed.
2 [060018A18, 060018A20) = 00000001 00000000
2 [060018A18, 060018A20) = 00000002 00000000
2 [060018A18, 060018A20) = 00000002 40000000
2 [060018A18, 060018A20) = 00000001 40000000
6 [060018A18, 060018A20) = 0000001E 20000000
6 [060018A18, 060018A20) = 0000001F 20000000
10 [060018A18, 060018A20) = 00000000 00000000
--//出現2次後4位是0x40000000的情況.可以理解這樣模式持有S mode的情況下,有X mode入隊,才會出現這樣的情況.
$ cat h1.sh
#! /bin/bash
source peek.sh 'gcs partitioned table hash' 30 | timestamp.pl >| /tmp/peeks.txt &
seq 30 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >| /tmp/latch_free.txt &
# 引數如下: @ latch.txt latch_name willing why where mode sleep_num
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 4 5 x 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 6 7 s 6 > /dev/null &
sleep 4.1
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 9 10 x 6 > /dev/null &
wait
$ grep -v '^.*: $' /tmp/peeks.txt | cut -c10- | uniq -c
1 SYSDATE LADDR
1 ------------------- ----------------
1 2019-04-16 10:11:26 0000000060018A18
1 Statement processed.
6 [060018A18, 060018A20) = 0000001C 20000000
1 [060018A18, 060018A20) = 00000001 00000000
5 [060018A18, 060018A20) = 00000001 40000000
6 [060018A18, 060018A20) = 0000001C 20000000
12 [060018A18, 060018A20) = 00000000 00000000
--//出現1次.最後我感覺指令碼寫的還是不好,每次都覆蓋前面的測試結果.加入時間變數,修改如下:
$ cat g1.sh
#! /bin/bash
zdate=$(date '+%H%M%S')
echo $zdate
source peek.sh 'gcs partitioned table hash' 30 | timestamp.pl >| /tmp/peeks_${zdate}.txt &
seq 30 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >| /tmp/latch_free_${zdate}.txt &
# 引數如下: @ latch.txt latch_name willing why where mode sleep_num
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 4 5 s 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 7 8 x 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 9 10 s 6 > /dev/null &
sleep 2.1
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 11 12 x 6 > /dev/null &
wait
--//大家可以自行組合,peek看到的值也許不重要,只要知道請求都是S mode下不會阻塞.
--//X模式下,請求的S模式都會導致序列化.同時S mode也會阻塞X mode就足夠了.最後測試一種情況看看:
$ cat i1.sh
#! /bin/bash
zdate=$(date '+%H%M%S')
echo $zdate
source peek.sh 'gcs partitioned table hash' 36 | timestamp.pl >| /tmp/peeks_${zdate}.txt &
seq 36 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >| /tmp/latch_free_${zdate}.txt &
# 引數如下: @ latch.txt latch_name willing why where mode sleep_num
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 4 5 x 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 7 8 s 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 9 10 s 6 > /dev/null &
sleep 2.1
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 11 12 s 6 > /dev/null &
wait
$ grep -v '^.*: $' /tmp/peeks_102719.txt | cut -c10- | uniq -c
1 SYSDATE LADDR
1 ------------------- ----------------
1 2019-04-16 10:27:19 0000000060018A18
1 Statement processed.
6 [060018A18, 060018A20) = 0000001C 20000000
1 [060018A18, 060018A20) = 00000001 00000000
6 [060018A18, 060018A20) = 00000002 00000000
5 [060018A18, 060018A20) = 00000001 00000000
18 [060018A18, 060018A20) = 00000000 00000000
--//可以最後請求S mode 沒有阻塞,需要18秒完成.如果修改如下:
$ cat i1.sh
#! /bin/bash
zdate=$(date '+%H%M%S')
echo $zdate
source peek.sh 'gcs partitioned table hash' 36 | timestamp.pl >| /tmp/peeks_${zdate}.txt &
seq 36 | xargs -I{} echo -e 'sqlplus -s -l / as sysdba <<< @latch_free\nsleep 1' | bash >| /tmp/latch_free_${zdate}.txt &
# 引數如下: @ latch.txt latch_name willing why where mode sleep_num
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 4 5 x 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 7 8 s 6 > /dev/null &
sleep 2
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 9 10 s 6 > /dev/null &
sleep 1.9
sqlplus /nolog @ shared_latch.txt 'gcs partitioned table hash' 1 11 12 s 6 > /dev/null &
wait
$ grep -v '^.*: $' /tmp/peeks_103201.txt | cut -c10- | uniq -c
1 SYSDATE LADDR
1 ------------------- ----------------
1 2019-04-16 10:32:01 0000000060018A18
1 Statement processed.
6 [060018A18, 060018A20) = 0000001C 20000000
18 [060018A18, 060018A20) = 00000001 00000000
12 [060018A18, 060018A20) = 00000000 00000000
--//可以發現我僅僅修改sleep 1.9秒,就導致後面3個S mode序列化.需要24秒完成.一旦序列化就很慢.
--//有點想作者說的那樣shared latch like enquence.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2641497/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20190416]exclusive latch測試指令碼.txt指令碼
- [20190416]檢視shared latch gets的變化.txt
- [20190419]shared latch spin count 2.txt
- [20190416]process allocation latch.txt
- [20220412]shared pool latch與使用sga heap的疑問2.txt
- [20220422]完善tpt ash ash_index_helperx指令碼2.txtIndex指令碼
- [20190416]11g下那些latch是Exclusive的.txt
- JMeter做效能測試(1)-效能壓測指令碼的生成以及完善和增強JMeter指令碼
- [20190419]shared latch spin count.txt
- [20190319]shared pool latch與library cache latch的簡單探究.txt
- [20210512]shared pool latch與library cache latch的簡單探究.txt
- [20210218]shared latch spin count 6.txt
- [20210218]shared latch spin count 5.txt
- PYTHON測試指令碼Python指令碼
- [20210506]完善tix指令碼.txt指令碼
- [20201202]完善sosi指令碼.txt指令碼
- [20210413]CBC latch再討論2.txt
- [20190415]關於shared latch(共享栓鎖).txt
- [20210708]使用那個shared pool latch.txt
- [20210623]完善清除aud指令碼.txt指令碼
- [20210803]使用那個shared pool latch(補充).txt
- [20231117]完善ashtt.sql指令碼.txtSQL指令碼
- [20211230]完善sql_id指令碼.txtSQL指令碼
- [20211122]完善descx.sql指令碼.txtSQL指令碼
- [20221012]完善spsw.sql指令碼.txtSQL指令碼
- [20221010]完善descz.sql指令碼.txtSQL指令碼
- [20221101]完善descz.sql指令碼.txtSQL指令碼
- [20221101]完善gts.sql指令碼.txtSQL指令碼
- [20230203]完善awr.sql指令碼.txtSQL指令碼
- [20230123]完善curheapz.sql指令碼.txtSQL指令碼
- [20210407]完善ti.sql指令碼.txtSQL指令碼
- [20210125]完善hide.sql指令碼.txtIDESQL指令碼
- [python] request 介面測試自動化指令碼轉化為 [locust] 效能測試指令碼Python指令碼
- [20210208][20200426]檢視shared latch gets的變化.txt
- 介面測試(apipost、jmeter和python指令碼)——測試工具APIJMeterPython指令碼
- iOS17 效能測試指令碼iOS指令碼
- [20190423]oradebug peek測試指令碼.txt指令碼
- [20191111]完善bind_cap.sql指令碼.txtSQL指令碼