转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/18461845 发生read by other session 等待事件,肯定是两个会话同时物理读同一个数据块,假设有两个会话,会话1发生物理读,会话2正要去物理读发现会话1正在物读理产生,此时会话2发生等待,此等待就是read by other session 等待事件。实验步骤如下:1丶开会话1,先查出会话1的进程号7376gyj@OCM> select spid from v$session s,v$process p where s.paddr=p.addr and sid in(select distinct sid from v$mystat);SPID------------------------73762丶刷新buffer cache,目的就是让select发生物理读gyj@OCM> alter system flush buffer_cache;System altered.3丶通过进程号7376,打开gdb[oracle@mydb ~]$ gdb $ORACLE_HOME/bin/oracle 7376GNU gdb Fedora (6.8-27.el5)Copyright (C) 2008 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or laterThis is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "x86_64-redhat-linux-gnu"...(no debugging symbols found)Attaching to program: /u01/app/oracle/product/11.2.0/bin/oracle, process 7376Reading symbols from /u01/app/oracle/product/11.2.0/lib/libodm11.so...(no debugging symbols found)...done.Loaded symbols for /u01/app/oracle/product/11.2.0/lib/libodm11.soReading symbols from /u01/app/oracle/product/11.2.0/lib/libcell11.so...done.Loaded symbols for /u01/app/oracle/product/11.2.0/lib/libcell11.soReading symbols from /u01/app/oracle/product/11.2.0/lib/libskgxp11.so...done.Loaded symbols for /u01/app/oracle/product/11.2.0/lib/libskgxp11.soReading symbols from /lib64/librt.so.1...done.Loaded symbols for /lib64/librt.so.1Reading symbols from /u01/app/oracle/product/11.2.0/lib/libnnz11.so...done.Loaded symbols for /u01/app/oracle/product/11.2.0/lib/libnnz11.soReading symbols from /u01/app/oracle/product/11.2.0/lib/libclsra11.so...done.Loaded symbols for /u01/app/oracle/product/11.2.0/lib/libclsra11.soReading symbols from /u01/app/oracle/product/11.2.0/lib/libdbcfg11.so...done.Loaded symbols for /u01/app/oracle/product/11.2.0/lib/libdbcfg11.soReading symbols from /u01/app/oracle/product/11.2.0/lib/libhasgen11.so...done.Loaded symbols for /u01/app/oracle/product/11.2.0/lib/libhasgen11.soReading symbols from /u01/app/oracle/product/11.2.0/lib/libskgxn2.so...done.Loaded symbols for /u01/app/oracle/product/11.2.0/lib/libskgxn2.soReading symbols from /u01/app/oracle/product/11.2.0/lib/libocr11.so...done.Loaded symbols for /u01/app/oracle/product/11.2.0/lib/libocr11.soReading symbols from /u01/app/oracle/product/11.2.0/lib/libocrb11.so...done.Loaded symbols for /u01/app/oracle/product/11.2.0/lib/libocrb11.soReading symbols from /u01/app/oracle/product/11.2.0/lib/libocrutl11.so...done.Loaded symbols for /u01/app/oracle/product/11.2.0/lib/libocrutl11.soReading symbols from /usr/lib64/libaio.so.1...done.Loaded symbols for /usr/lib64/libaio.so.1Reading symbols from /lib64/libdl.so.2...done.Loaded symbols for /lib64/libdl.so.2Reading symbols from /lib64/libm.so.6...done.Loaded symbols for /lib64/libm.so.6Reading symbols from /lib64/libpthread.so.0...done.[Thread debugging using libthread_db enabled][New Thread 0x2b0b8fef0910 (LWP 7376)]Loaded symbols for /lib64/libpthread.so.0Reading symbols from /lib64/libnsl.so.1...done.Loaded symbols for /lib64/libnsl.so.1Reading symbols from /lib64/libc.so.6...done.Loaded symbols for /lib64/libc.so.6Reading symbols from /lib64/ld-linux-x86-64.so.2...done.Loaded symbols for /lib64/ld-linux-x86-64.so.2Reading symbols from /usr/lib64/libnuma.so.1...done.Loaded symbols for /usr/lib64/libnuma.so.1Reading symbols from /lib64/libnss_files.so.2...done.Loaded symbols for /lib64/libnss_files.so.2Reading symbols from /u01/app/oracle/product/11.2.0/lib/libnque11.so...done.Loaded symbols for /u01/app/oracle/product/11.2.0/lib/libnque11.so0x0000003f0d40d290 in __read_nocancel () from /lib64/libpthread.so.0(gdb)4丶在会话1,执行select语句,此时select被阻塞gyj@OCM> select * from gyj_test where id=1;5丶在gdb设断点,用等待事件的函数,并运行(gdb) b kslwtbctxBreakpoint 1 at 0x8f9a5c2(gdb) cContinuing.6丶查等待事件kslwtbctx函数的第一个参数,用命令info all-register显示寄存器(gdb) info all-registerrax 0x62657100 1650815232rbx 0x15c 348rcx 0x0 0rdx 0x1 1rsi 0x7a59 31321rdi 0x7fff1c576d40 140733668879680rbp 0x7fff1c576ce0 0x7fff1c576ce0rsp 0x7fff1c576ce0 0x7fff1c576ce0r8 0x2 2r9 0x25 37r10 0x7 7r11 0x0 0r12 0x0 0r13 0xbb0c348 196133704r14 0xbb09d40 196123968r15 0x1 1rip 0x8f9a5c2 0x8f9a5c2eflags 0x246 [ PF ZF IF ]cs 0x33 51ss 0x2b 43ds 0x0 0es 0x0 0fs 0x0 0gs 0x0 0st0 0 (raw 0x00000000000000000000)---Type to continue, or q to quit---st1 0 (raw 0x00000000000000000000)st2 0 (raw 0x00000000000000000000)st3 0 (raw 0x00000000000000000000)st4 0 (raw 0x00000000000000000000)st5 0 (raw 0x00000000000000000000)st6 73280 (raw 0x400f8f20000000000000)st7 73280 (raw 0x400f8f20000000000000)fctrl 0x27f 639fstat 0x0 0ftag 0xffff 65535fiseg 0x0 0fioff 0x9394e95 154750613foseg 0x7fff 32767fooff 0x1c573f50 475479888fop 0x0 07丶找到第一个参数rdi 0x7fff1c576d408丶用x/32命令查内存中32个字节gdb) x/32 0x7fff1c576d400x7fff1c576d40: 0x1c577a59 0x00007fff 0x1c576e50 0x00007fff0x7fff1c576d50: 0x1c576ee0 0x00007fff 0x0918adf2 0x000000000x7fff1c576d60: 0x00000000 0x00000000 0x00000000 0x000000000x7fff1c576d70: 0x00000000 0x00000001 0x00000000 0x000000000x7fff1c576d80: 0x002adb17 0x00000000 0x00000000 0x000000000x7fff1c576d90: 0x00000000 0x00000000 0x00000001 0x000000000x7fff1c576da0: 0x09b958cc 0x00000000 0x0000015c 0x000000000x7fff1c576db0: 0x7fffffff 0x00000000 0x62657100 0x000000009丶找到0x0000015c,通过此等待事件号,找等待事件gyj@OCM> select name from v$event_name where event# in(select to_number(\'15c\',\'xxxxxxxxxxxxxx\') from dual);NAME----------------------------------------------------------------SQL*Net message to client10丶重复第5丶6丶7丶8丶9步(注用从第5步的c命令开始)(gdb) cContinuing.Breakpoint 1, 0x0000000008f9a5c2 in kslwtbctx ()(gdb) info all-registerrax 0x0 0rbx 0x2000 8192rcx 0x0 0rdx 0x0 0rsi 0x0 0rdi 0x7fff1c574c38 140733668871224rbp 0x7fff1c574970 0x7fff1c574970rsp 0x7fff1c574970 0x7fff1c574970r8 0x5bbb295 96187029r9 0x2f8b5f0 49853936r10 0x52da848e 1390052494r11 0x2b0b9057e7a8 47328666314664r12 0x99837da8 2575531432r13 0x0 0r14 0x0 0r15 0x99437498 2571334808rip 0x8f9a5c2 0x8f9a5c2eflags 0x246 [ PF ZF IF ]cs 0x33 51ss 0x2b 43ds 0x0 0es 0x0 0fs 0x0 0gs 0x0 0st0 0 (raw 0x00000000000000000000)---Type to continue, or q to quit---st1 0 (raw 0x00000000000000000000)st2 0 (raw 0x00000000000000000000)st3 0 (raw 0x00000000000000000000)st4 0 (raw 0x00000000000000000000)st5 0 (raw 0x00000000000000000000)st6 73280 (raw 0x400f8f20000000000000)st7 73280 (raw 0x400f8f20000000000000)fctrl 0x27f 639fstat 0x0 0ftag 0xffff 65535fiseg 0x0 0fioff 0x9394e95 154750613foseg 0x7fff 32767fooff 0x1c573f50 475479888fop 0x0 0xmm0 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 }, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}xmm1 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 }, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}xmm2 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 }, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}xmm3 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0, 0x0, 0x0, 0x0, 0x54, 0x3, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0x0, 0x0, 0x354, 0x1, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x10354, 0x0, 0x0}, v2_int64 = { 0x1035400000000, 0x0}, uint128 = 0x00000000000000000001035400000000}xmm4 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x64, 0x0 }, v8_int16 = {0x64, 0x0,---Type to continue, or q to quit--- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x64, 0x0, 0x0, 0x0}, v2_int64 = {0x64, 0x0}, uint128 = 0x00000000000000000000000000000064}xmm5 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x32, 0xa3, 0xd7, 0x2, 0x0 }, v8_int16 = {0xa332, 0x2d7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x2d7a332, 0x0, 0x0, 0x0}, v2_int64 = {0x2d7a332, 0x0}, uint128 = 0x00000000000000000000000002d7a332}xmm6 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 }, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}xmm7 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0xda, 0x87, 0xd7, 0x2, 0x0 }, v8_int16 = {0x87da, 0x2d7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x2d787da, 0x0, 0x0, 0x0}, v2_int64 = {0x2d787da, 0x0}, uint128 = 0x00000000000000000000000002d787da}xmm8 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 }, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}xmm9 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 }, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}xmm10 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 }, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}xmm11 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 }, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}xmm12 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x18, 0xe, 0x73, 0x90, 0xb, 0x2b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0xe18, 0x9073, 0x2b0b, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x90730e18, 0x2b0b, 0x0, 0x0}, v2_int64 = {0x2b0b90730e18, 0x0}, uint128 = 0x000000000000000000002b0b90730e18}xmm13 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 }, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}xmm14 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 }, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}xmm15 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 }, v8_int16 = {0x0, 0x0, 0x0, 0x0,---Type to continue, or q to quit--- 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}mxcsr 0x1fa1 [ IE PE IM DM ZM OM UM PM ](gdb)(gdb) x/32 0x7fff1c574c380x7fff1c574c38: 0x08f97a59 0x00000000 0x9079c6d8 0x00002b0b0x7fff1c574c48: 0x90742970 0x00002b0b 0x9079c748 0x00002b0b0x7fff1c574c58: 0x1c574df0 0x00007fff 0x9079c748 0x00002b0b0x7fff1c574c68: 0x9079c6d8 0x00002b0b 0x00000000 0x000000000x7fff1c574c78: 0x00000000 0x00000000 0x00000013 0x200000000x7fff1c574c88: 0x00000000 0x00000000 0x00000001 0x000000000x7fff1c574c98: 0x0a0fcd50 0x00000000 0x00000092 0x000000000x7fff1c574ca8: 0x7fffffff 0x00000000 0x00000006 0x00000000(gdb)11丶找到0x00000092,通过此等待事件号,找等待事件0x00000092gyj@OCM> gyj@OCM> select name from v$event_name where event# in(select to_number(\'92\',\'xxxxxxxxxxxxxx\') from dual);NAME----------------------------------------------------------------db file sequential read说明此时会话1发生了物理读(db file sequential read等待事件你懂我)12丶打开会话2(此会话2号的SID=146),并在会话2执行SELECT语句,此时SELECT也被阻塞了gyj@OCM> select sid from v$mystat where rownum=1; SID---------- 146 gyj@OCM> select * from gyj_test where id=1;13丶打开一个会话3,看会话2(此会话2号的SID=146)的等待事件sys@OCM> select sid ,event from v$session_wait where sid=146 and wait_class\'Idle\'; SID EVENT---------- ---------------------------------------------------------------- 146 read by other session哈哈。。。终于发现了read by other session等待事件,以后可以用同样的方法去研究其它等待事件!QQ:252803295技术交流QQ群:DSI&Core Search Ⅰ 群:127149411(2000人技术群:未满)DSI&Core Search Ⅱ 群:177089463(1000人技术群:未满)DSI&Core Search Ⅲ 群:284596437(500人技术群:未满)DSI&Core Search Ⅳ 群:192136702(500人技术群:未满)DSI&Core Search Ⅴ 群:285030382(500人闲聊群:未满)MAIL:[email protected]: http://blog.csdn.net/guoyjoeWEIBO:http://weibo.com/guoyJoe0218ITPUB: http://www.itpub.net/space-uid-28460966.htmlOCM: http://education.oracle.com/education/otn/YGuo.HTM ACONG: http://www.acoug.org/category/membership 12-14 13:02