[20190409]latch get 参数where and why.txt
--//这一阵子一直在探究latch,mutex的问题,思路好乱.放假在https://andreynikolaev.wordpress.com看了许多链接.
--//被里面的X$搞得有点晕.慢慢理解看看:
kslgetl(laddr, wait, why, where) – Get exclusive latch
--//感觉作者这里写错了,应该是kslgetl(laddr, wait, where, why).这样才与下面的链接对上.
More precisely, to request the latch Oracle kernel needs:
--//更准确地说,要请求闩锁Oracle内核需要:
laddress -- address of latch in SGA
wait -- flag. If true, this is latch get in willing-to-wait mode..
where -- code for location from where the latch is acquired.
why -- context why the latch is acquired at this where.
--//我主要关注where,why如何取值.
https://fritshoogland.wordpress.com/2015/07/17/oracle-12-and-latches/
1-latch address
2-immediate get (0 means yes, 1 means no)
3-where (X$KSLLW.INDX)
4-why (X$KSLWSC.INDX)
5-mode (8=shared,16=exclusive; only for ksl_get_shared_latch function)
--//以作者写的例子看看latch='DMON Work Queues 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
SYS@book> select addr, name from v$latch where name='DMON Work Queues Latch';
ADDR NAME
---------------- ----------------------------------------
000000006004C300 DMON Work Queues Latch
SYS@book> select addr, name from v$latch_parent where name='DMON Work Queues Latch';
ADDR NAME
---------------- ----------------------------------------
000000006004C300 DMON Work Queues Latch
SYS@book> select addr, name from v$latch_children where name='DMON Work Queues Latch';
no rows selected
--//仅仅存在父拴锁.
2.首先看看why的取值:
--//4-why (X$KSLWSC.INDX)
SYS@book> select * from x$kslwsc where ksllasnam ='DMON Work Queues Latch';
ADDR INDX INST_ID KSLNOWTF KSLSLEEP KSLWSCWSL KSLWSCLTHG KSLLASNAM
---------------- ---------- ---------- ---------- ---------- ---------- ---------- ----------------------
00000000861C08C0 4972 1 0 1 1 0 DMON Work Queues Latch
00000000861C08E0 4973 1 0 0 0 0 DMON Work Queues Latch
00000000861C0900 4974 1 0 0 0 0 DMON Work Queues Latch
00000000861C0920 4975 1 0 0 0 0 DMON Work Queues Latch
00000000861C0940 4976 1 0 0 0 0 DMON Work Queues Latch
00000000861C0960 4977 1 0 0 0 0 DMON Work Queues Latch
00000000861C0980 4978 1 0 0 0 0 DMON Work Queues Latch
00000000861C09A0 4979 1 0 0 0 0 DMON Work Queues Latch
00000000861C09C0 4980 1 0 0 0 0 DMON Work Queues Latch
00000000861C09E0 4981 1 0 0 0 0 DMON Work Queues Latch
00000000861C0A00 4982 1 0 0 0 0 DMON Work Queues Latch
00000000861C0A20 4983 1 0 0 0 0 DMON Work Queues Latch
00000000861C0A40 4984 1 0 0 0 0 DMON Work Queues Latch
00000000861C0A60 4985 1 0 0 0 0 DMON Work Queues Latch
00000000861C0A80 4986 1 0 0 0 0 DMON Work Queues Latch
00000000861C0AA0 4987 1 0 0 0 0 DMON Work Queues Latch
00000000861C0AC0 4988 1 0 0 0 0 DMON Work Queues Latch
00000000861C0AE0 4989 1 0 0 0 0 DMON Work Queues Latch
00000000861C0B00 4990 1 0 0 0 0 DMON Work Queues Latch
00000000861C0B20 4991 1 0 0 0 0 DMON Work Queues Latch
00000000861C0B40 4992 1 0 0 0 0 DMON Work Queues Latch
00000000861C0B60 4993 1 0 0 0 0 DMON Work Queues Latch
00000000861C0B80 4994 1 0 0 0 0 DMON Work Queues Latch
00000000861C0BA0 4995 1 0 0 0 0 DMON Work Queues Latch
00000000861C0BC0 4996 1 0 0 0 0 DMON Work Queues Latch
00000000861C0BE0 4997 1 0 0 0 0 DMON Work Queues Latch
00000000861C0C00 4998 1 0 0 0 0 DMON Work Queues Latch
00000000861C0C20 4999 1 0 0 0 0 DMON Work Queues Latch
00000000861C0C40 5000 1 0 0 0 0 DMON Work Queues Latch
00000000861C0C60 5001 1 0 0 0 0 DMON Work Queues Latch
00000000861C0C80 5002 1 0 0 0 0 DMON Work Queues Latch
00000000861C0CA0 5003 1 0 0 0 0 DMON Work Queues Latch
00000000861C0CC0 5004 1 0 0 0 0 DMON Work Queues Latch
00000000861C0CE0 5005 1 0 0 0 0 DMON Work Queues Latch
00000000861C0D00 5006 1 0 0 0 0 DMON Work Queues Latch
00000000861C0D20 5007 1 0 0 0 0 DMON Work Queues Latch
00000000861C0D40 5008 1 0 0 0 0 DMON Work Queues Latch
00000000861C0D60 5009 1 0 0 0 0 DMON Work Queues Latch
00000000861C0D80 5010 1 0 0 0 0 DMON Work Queues Latch
00000000861C0DA0 5011 1 0 0 0 0 DMON Work Queues Latch
00000000861C0DC0 5012 1 0 0 0 0 DMON Work Queues Latch
00000000861C0DE0 5013 1 0 0 0 0 DMON Work Queues Latch
00000000861C0E00 5014 1 0 0 0 0 DMON Work Queues Latch
00000000861C0E20 5015 1 0 0 0 0 DMON Work Queues Latch
00000000861C0E40 5016 1 0 0 0 0 DMON Work Queues Latch
00000000861C0E60 5017 1 0 0 0 0 DMON Work Queues Latch
46 rows selected.
--//可以看出取值在4972-5017之间.
SYS@book> select * from x$ksllw where indx between 4972 and 5017;
ADDR INDX INST_ID KSLLWNAM KSLLWLBL
---------------- ---------- ---------- --------------------------- -----------------
0000000009AB0CC0 4972 1 rfifdrcxch
0000000009AB0CD0 4973 1 rfifreqch
0000000009AB0CE0 4974 1 rfm_do_hc
0000000009AB0CF0 4975 1 rfm_init_boot_te1
0000000009AB0D00 4976 1 rfm_init_boot_te2
0000000009AB0D10 4977 1 rfm_init_boot_te3
0000000009AB0D20 4978 1 rfm_init_boot_te4
0000000009AB0D30 4979 1 rfm_free_te
0000000009AB0D40 4980 1 rfm_setup_te
0000000009AB0D50 4981 1 rfmeadvphs
0000000009AB0D60 4982 1 rfmdophs
0000000009AB0D70 4983 1 rfmdolocalop
0000000009AB0D80 4984 1 rfmdowrop1
0000000009AB0D90 4985 1 rfmdowrop2
0000000009AB0DA0 4986 1 rfmdowrop3
0000000009AB0DB0 4987 1 rfmdomonproperty1
0000000009AB0DC0 4988 1 rfmdomonproperty2
0000000009AB0DD0 4989 1 rfm_init_boot_te5
0000000009AB0DE0 4990 1 rfmdoremoteop1
0000000009AB0DF0 4991 1 rfmdoremoteop2
0000000009AB0E00 4992 1 rfmdodisable
0000000009AB0E10 4993 1 rfm_do_switchover1
0000000009AB0E20 4994 1 rfm_do_switchover2
0000000009AB0E30 4995 1 rfm_do_failover
0000000009AB0E40 4996 1 rfmtecb1
0000000009AB0E50 4997 1 rfmtecb2
0000000009AB0E60 4998 1 rfm_quiesce_site
0000000009AB0E70 4999 1 rfm_quiesce_instance
0000000009AB0E80 5000 1 rfm_enable_object
0000000009AB0E90 5001 1 rfmdsite
0000000009AB0EA0 5002 1 rfm_execute_task_fn1
0000000009AB0EB0 5003 1 rfm_execute_task_fn2
0000000009AB0EC0 5004 1 rfm_inst_phase_dispatch1
0000000009AB0ED0 5005 1 rfm_inst_phase_dispatch2
0000000009AB0EE0 5006 1 rfm_inst_phase_dispatch3
0000000009AB0EF0 5007 1 rfm_get_chief_lock
0000000009AB0F00 5008 1 rfm_release_chief_lock
0000000009AB0F10 5009 1 rfmhcadvphs
0000000009AB0F20 5010 1 rfm_do_client_hc
0000000009AB0F30 5011 1 rfm_execute_sprobe
0000000009AB0F40 5012 1 rfm_broker_cleanup
0000000009AB0F50 5013 1 rfm_init_dmon
0000000009AB0F60 5014 1 rfrm_set_param
0000000009AB0F70 5015 1 rfm_init_boot_te6
0000000009AB0F80 5016 1 rfm_phase_dispatch_sby1
0000000009AB0F90 5017 1 rfm_phase_dispatch_sby2
46 rows selected.
--//KSLLWNAM 对应的就是location.通过gV$LATCH_MISSES 定义修改一下增加indx如下:
/* Formatted on 2019/4/9 12:10:49 (QP5 v5.269.14213.34769) */
SELECT t1.inst_id inst_id
,t1.indx indx
,t1.ksllasnam PARENT_NAME
,t2.ksllwnam "WHERE"
,t1.kslnowtf NWFAIL_COUNT
,t1.kslsleep SLEEP_COUNT
,t1.kslwscwsl WTR_SLP_COUNT
,t1.kslwsclthg LONGHOLD_COUNT
,t2.ksllwnam LOCATION
FROM x$ksllw t2, x$kslwsc t1
WHERE t2.indx = t1.indx AND t1.ksllasnam LIKE 'DMON Work Queues Latch';
--//location 与where 对应的内容一样.
INST_ID INDX PARENT_NAME WHERE NWFAIL_COUNT SLEEP_COUNT WTR_SLP_COUNT LONGHOLD_COUNT LOCATION
---------- ---------- ----------------------- ------------------------------ ------------ ----------- ------------- -------------- ------------------------------
1 4972 DMON Work Queues Latch rfifdrcxch 0 1 1 0 rfifdrcxch
1 4973 DMON Work Queues Latch rfifreqch 0 0 0 0 rfifreqch
1 4974 DMON Work Queues Latch rfm_do_hc 0 0 0 0 rfm_do_hc
1 4975 DMON Work Queues Latch rfm_init_boot_te1 0 0 0 0 rfm_init_boot_te1
1 4976 DMON Work Queues Latch rfm_init_boot_te2 0 0 0 0 rfm_init_boot_te2
1 4977 DMON Work Queues Latch rfm_init_boot_te3 0 0 0 0 rfm_init_boot_te3
1 4978 DMON Work Queues Latch rfm_init_boot_te4 0 0 0 0 rfm_init_boot_te4
1 4979 DMON Work Queues Latch rfm_free_te 0 0 0 0 rfm_free_te
1 4980 DMON Work Queues Latch rfm_setup_te 0 0 0 0 rfm_setup_te
1 4981 DMON Work Queues Latch rfmeadvphs 0 0 0 0 rfmeadvphs
1 4982 DMON Work Queues Latch rfmdophs 0 0 0 0 rfmdophs
1 4983 DMON Work Queues Latch rfmdolocalop 0 0 0 0 rfmdolocalop
1 4984 DMON Work Queues Latch rfmdowrop1 0 0 0 0 rfmdowrop1
1 4985 DMON Work Queues Latch rfmdowrop2 0 0 0 0 rfmdowrop2
1 4986 DMON Work Queues Latch rfmdowrop3 0 0 0 0 rfmdowrop3
1 4987 DMON Work Queues Latch rfmdomonproperty1 0 0 0 0 rfmdomonproperty1
1 4988 DMON Work Queues Latch rfmdomonproperty2 0 0 0 0 rfmdomonproperty2
1 4989 DMON Work Queues Latch rfm_init_boot_te5 0 0 0 0 rfm_init_boot_te5
1 4990 DMON Work Queues Latch rfmdoremoteop1 0 0 0 0 rfmdoremoteop1
1 4991 DMON Work Queues Latch rfmdoremoteop2 0 0 0 0 rfmdoremoteop2
1 4992 DMON Work Queues Latch rfmdodisable 0 0 0 0 rfmdodisable
1 4993 DMON Work Queues Latch rfm_do_switchover1 0 0 0 0 rfm_do_switchover1
1 4994 DMON Work Queues Latch rfm_do_switchover2 0 0 0 0 rfm_do_switchover2
1 4995 DMON Work Queues Latch rfm_do_failover 0 0 0 0 rfm_do_failover
1 4996 DMON Work Queues Latch rfmtecb1 0 0 0 0 rfmtecb1
1 4997 DMON Work Queues Latch rfmtecb2 0 0 0 0 rfmtecb2
1 4998 DMON Work Queues Latch rfm_quiesce_site 0 0 0 0 rfm_quiesce_site
1 4999 DMON Work Queues Latch rfm_quiesce_instance 0 0 0 0 rfm_quiesce_instance
1 5000 DMON Work Queues Latch rfm_enable_object 0 0 0 0 rfm_enable_object
1 5001 DMON Work Queues Latch rfmdsite 0 0 0 0 rfmdsite
1 5002 DMON Work Queues Latch rfm_execute_task_fn1 0 0 0 0 rfm_execute_task_fn1
1 5003 DMON Work Queues Latch rfm_execute_task_fn2 0 0 0 0 rfm_execute_task_fn2
1 5004 DMON Work Queues Latch rfm_inst_phase_dispatch1 0 0 0 0 rfm_inst_phase_dispatch1
1 5005 DMON Work Queues Latch rfm_inst_phase_dispatch2 0 0 0 0 rfm_inst_phase_dispatch2
1 5006 DMON Work Queues Latch rfm_inst_phase_dispatch3 0 0 0 0 rfm_inst_phase_dispatch3
1 5007 DMON Work Queues Latch rfm_get_chief_lock 0 0 0 0 rfm_get_chief_lock
1 5008 DMON Work Queues Latch rfm_release_chief_lock 0 0 0 0 rfm_release_chief_lock
1 5009 DMON Work Queues Latch rfmhcadvphs 0 0 0 0 rfmhcadvphs
1 5010 DMON Work Queues Latch rfm_do_client_hc 0 0 0 0 rfm_do_client_hc
1 5011 DMON Work Queues Latch rfm_execute_sprobe 0 0 0 0 rfm_execute_sprobe
1 5012 DMON Work Queues Latch rfm_broker_cleanup 0 0 0 0 rfm_broker_cleanup
1 5013 DMON Work Queues Latch rfm_init_dmon 0 0 0 0 rfm_init_dmon
1 5014 DMON Work Queues Latch rfrm_set_param 0 0 0 0 rfrm_set_param
1 5015 DMON Work Queues Latch rfm_init_boot_te6 0 0 0 0 rfm_init_boot_te6
1 5016 DMON Work Queues Latch rfm_phase_dispatch_sby1 0 0 0 0 rfm_phase_dispatch_sby1
1 5017 DMON Work Queues Latch rfm_phase_dispatch_sby2 0 0 0 0 rfm_phase_dispatch_sby2
46 rows selected.
3.where的取值:
--//3-where (X$KSLLW.INDX)
SYS@book> select * from X$KSLLW where indx between 4972 and 5017 ;
ADDR INDX INST_ID KSLLWNAM KSLLWLBL
---------------- ---------- ---------- ----------------------------- ----------------------------------
0000000009AB0CC0 4972 1 rfifdrcxch
0000000009AB0CD0 4973 1 rfifreqch
0000000009AB0CE0 4974 1 rfm_do_hc
0000000009AB0CF0 4975 1 rfm_init_boot_te1
0000000009AB0D00 4976 1 rfm_init_boot_te2
0000000009AB0D10 4977 1 rfm_init_boot_te3
0000000009AB0D20 4978 1 rfm_init_boot_te4
0000000009AB0D30 4979 1 rfm_free_te
0000000009AB0D40 4980 1 rfm_setup_te
0000000009AB0D50 4981 1 rfmeadvphs
0000000009AB0D60 4982 1 rfmdophs
0000000009AB0D70 4983 1 rfmdolocalop
0000000009AB0D80 4984 1 rfmdowrop1
0000000009AB0D90 4985 1 rfmdowrop2
0000000009AB0DA0 4986 1 rfmdowrop3
0000000009AB0DB0 4987 1 rfmdomonproperty1
0000000009AB0DC0 4988 1 rfmdomonproperty2
0000000009AB0DD0 4989 1 rfm_init_boot_te5
0000000009AB0DE0 4990 1 rfmdoremoteop1
0000000009AB0DF0 4991 1 rfmdoremoteop2
0000000009AB0E00 4992 1 rfmdodisable
0000000009AB0E10 4993 1 rfm_do_switchover1
0000000009AB0E20 4994 1 rfm_do_switchover2
0000000009AB0E30 4995 1 rfm_do_failover
0000000009AB0E40 4996 1 rfmtecb1
0000000009AB0E50 4997 1 rfmtecb2
0000000009AB0E60 4998 1 rfm_quiesce_site
0000000009AB0E70 4999 1 rfm_quiesce_instance
0000000009AB0E80 5000 1 rfm_enable_object
0000000009AB0E90 5001 1 rfmdsite
0000000009AB0EA0 5002 1 rfm_execute_task_fn1
0000000009AB0EB0 5003 1 rfm_execute_task_fn2
0000000009AB0EC0 5004 1 rfm_inst_phase_dispatch1
0000000009AB0ED0 5005 1 rfm_inst_phase_dispatch2
0000000009AB0EE0 5006 1 rfm_inst_phase_dispatch3
0000000009AB0EF0 5007 1 rfm_get_chief_lock
0000000009AB0F00 5008 1 rfm_release_chief_lock
0000000009AB0F10 5009 1 rfmhcadvphs
0000000009AB0F20 5010 1 rfm_do_client_hc
0000000009AB0F30 5011 1 rfm_execute_sprobe
0000000009AB0F40 5012 1 rfm_broker_cleanup
0000000009AB0F50 5013 1 rfm_init_dmon
0000000009AB0F60 5014 1 rfrm_set_param
0000000009AB0F70 5015 1 rfm_init_boot_te6
0000000009AB0F80 5016 1 rfm_phase_dispatch_sby1
0000000009AB0F90 5017 1 rfm_phase_dispatch_sby2
46 rows selected.
--//感觉不对,不大可能还是indx.
--//链接 http://andreynikolaev.wordpress.com/2010/04/12/latch-internals-information-sources/
Also, these strings present as "Location from where latch is held" in process state object dumps. For example, look
at the process holding cache buffers chains latch:
--//此外,这些字符串在进程状态对象转储中以"持有锁的位置"的形式出现。例如,查看保存缓冲区链锁存的进程:
PROCESS 299:
----------------------------------------
SO: 0x2d93be720, type: 2, owner: (nil), flag: INIT/-/-/0x00
(process) Oracle pid=299, calls cur/top: 0x2e9028a38/0x2e9028a38, flag: (0)
…
(latch info) wait_event=0 bits=2
holding 2dee1ac50 Child cache buffers chains level=1 child#=124200
Location from where latch is held: kcbgtcr: fast path:
Context saved from call: 39022946
…
"Why" meaning for some of "where" may be guessed from ksllwlbl column of x$ksllw. From the above listing one can
conclude that "why" contain the SGA chunk address for shared pool latch and the session address for session idle bit
latch correspondingly.
--//从x$ksllw的ksllwlbl列中可以猜到"why"的意思是"WHERE"。从上面的列表中可以得出结论,"why"包含用于共享池闩锁的SGA块地址
--//,以及相应地包含会话空闲位闩锁的会话地址。
--//KSLLWLBL列显示的是空?视乎要按照上下文猜测why.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-2640890/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/267265/viewspace-2640890/