{"id":1469,"date":"2012-11-26T23:40:06","date_gmt":"2012-11-26T15:40:06","guid":{"rendered":"https:\/\/yangtingkun.net\/?p=1469"},"modified":"2013-08-02T16:46:14","modified_gmt":"2013-08-02T08:46:14","slug":"vsession%e8%ae%b0%e5%bd%95%e7%9a%84blocking_session%e9%94%99%e8%af%af","status":"publish","type":"post","link":"https:\/\/yangtingkun.net\/?p=1469","title":{"rendered":"V$SESSION\u8bb0\u5f55\u7684BLOCKING_SESSION\u9519\u8bef"},"content":{"rendered":"<p>\u8bb0\u5f55\u4e00\u4e2a\u5f88\u8be1\u5f02\u7684\u95ee\u9898\uff0c\u5728\u8fdb\u884c\u4e00\u4e2a\u6d4b\u8bd5\u65f6\u78b0\u5230\u7684\uff0cV$SESSION\u4e2d\u8bb0\u5f55\u7684BLOCKING_SESSION\u4fe1\u606f\u662f\u9519\u8bef\u7684\uff0c\u53ef\u60dc\u8fd9\u4e2a\u95ee\u9898\u5f53\u65f6\u6ca1\u6709\u6ce8\u610f\uff0c\u540e\u7eed\u4e5f\u65e0\u6cd5\u518d\u91cd\u73b0\u51fa\u6765\uff0c\u53ea\u597d\u4f5c\u4e3a\u4e00\u4e2a\u73b0\u8c61\u8bb0\u5f55\u4e00\u4e0b\uff0cOracle\u7ed9\u51fa\u7684\u4e00\u4e9b\u4fe1\u606f\u770b\u6765\u4e5f\u662f\u4e0d\u5b8c\u5168\u53ef\u4fe1\u7684\u3002<br \/>\n\u5728\u4f1a\u8bdd1\u6267\u884c\uff1a<\/p>\n<pre lang='SQL'>[tingkun.yang@node1 ~]$ sqlplus test\/test\r\nSQL*Plus: Release 10.2.0.5.0 - Production on Sun Nov 25 04:04:00 2012\r\nCopyright (c) 1982, 2010, Oracle. All Rights Reserved.\r\nConnected to:\r\nOracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production\r\nWith the Partitioning, Real Application Clusters, OLAP, Data Mining\r\nand Real Application Testing options\r\nSQL> set pages 100 lines 140\r\nSQL> create table t_lock (id number, name varchar2(30), gender varchar2(8));\r\nTable created.\r\nSQL> insert into t_lock values (1, 'a', 'm');\r\n1 row created.\r\nSQL> insert into t_lock values (2, 'b', 'f');\r\n1 row created.\r\nSQL> commit;\r\nCommit complete.\r\nSQL> update t_lock set name = 'c' where id = 1;\r\n1 row updated.\r\nSQL> select sid from v$mystat where rownum = 1;\r\nSID\r\n----------\r\n       151<\/pre>\n<p>\u5728\u4f1a\u8bdd2\u6267\u884c\u540c\u4e00\u884c\u7684\u66f4\u65b0\uff0c\u88ab\u9501\u5b9a\uff1a<\/p>\n<pre lang='SQL'>[tingkun.yang@node1 ~]$ sqlplus test\/test\r\nSQL*Plus: Release 10.2.0.5.0 - Production on Sun Nov 25 04:03:27 2012\r\nCopyright (c) 1982, 2010, Oracle. All Rights Reserved.\r\n\r\nConnected to:\r\nOracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production\r\nWith the Partitioning, Real Application Clusters, OLAP, Data Mining\r\nand Real Application Testing options\r\nSQL> set pages 100 lines 120\r\nSQL> update t_lock set name = 'd' where id = 1;<\/pre>\n<p>\u5728\u4f1a\u8bdd3\u4e0a\u6267\u884c\u5bf9V$SESSION\u7684\u67e5\u8be2\uff0c\u5f53\u65f6\u6ca1\u6709\u592a\u6ce8\u610f\uff1a<\/p>\n<pre lang='SQL'>SQL> conn \/ as sysdba\r\nConnected.\r\nSQL> select sid, event, blocking_session from v$session where usernamE = 'TEST';\r\n       SID EVENT                                                            BLOCKING_SESSION\r\n---------- ---------------------------------------------------------------- ----------------\r\n       131 SQL*Net message from client\r\n       151 SQL*Net message from client\r\nSQL> select sid, event, blocking_session from v$session where usernamE = 'TEST';\r\n       SID EVENT                                                            BLOCKING_SESSION\r\n---------- ---------------------------------------------------------------- ----------------\r\n       131 enq: TX - row lock contention                                                 161\r\n       151 SQL*Net message from client<\/pre>\n<p>\u968f\u540e\u5728\u4f1a\u8bdd1\u6267\u884c\u4e86ROLLBACK\uff1a<\/p>\n<pre lang='SQL'>SQL> roll;\r\nRollback complete.<\/pre>\n<p>\u68c0\u67e5\u4e86\u4f1a\u8bdd2\u7684\u8fde\u63a5\u4fe1\u606f\uff1a<\/p>\n<pre lang='SQL'>\r\n1 row updated.\r\nSQL> select sid from v$mystat where rownum = 1;\r\n       SID\r\n----------\r\n       131<\/pre>\n<p>\u8fd9\u65f6\u624d\u53d1\u73b0\uff0c\u4e4b\u524d\u67e5\u8be2\u7684V$SESSION\u4e2d\u7684BLOCKING_SESSION\u4fe1\u606f\u662f\u9519\u8bef\u7684\u3002\u5f53\u524d\u6570\u636e\u5e93\u53ea\u6709\u4e24\u4e2a\u6d4b\u8bd5\u4f1a\u8bdd\uff0c\u5206\u522b\u662f131\u548c151\uff0c\u800cBLOCKING_SESSION\u7ed9\u51fa\u7684\u7ed3\u679c\u5c45\u7136\u662f161\u3002\u867d\u7136V$SESSION\u4e2d\u8fd8\u6709BLOCKING_SESSION_STATUS\u5217\u6765\u8868\u793a\u5f53\u524d\u7684BLOCKING_SESSION\u662f\u5426\u6709\u610f\u4e49\uff0c\u4f46\u662f\u4e00\u822c\u800c\u8a00\uff0c\u5982\u679cBLOCKING_SESSION_STATUS\u7684\u503c\u4e0d\u662fVALID\uff0c\u90a3\u4e48BLOCKING_SESSION\u7684\u503c\u4f1a\u662fNULL\uff0c\u4f46\u662f\u50cf\u8fd9\u79cd\u503c\u672c\u8eab\u5c31\u662f\u9519\u8bef\u7684\uff0c\u8fd8\u662f\u7b2c\u4e00\u6b21\u78b0\u5230\u3002<br \/>\n\u7531\u4e8e\u6ca1\u6709\u529e\u6cd5\u91cd\u73b0\uff0c\u73b0\u5728\u786e\u5b9a\u4e0d\u4e86Oracle\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u8fd9\u79cd\u95ee\u9898\uff0c\u53ea\u80fd\u5148\u4f5c\u4e3a\u4e00\u4e2a\u5f02\u5e38\u6848\u4f8b\u8bb0\u5f55\u4e00\u4e0b\uff0c\u5982\u679c\u4ee5\u540e\u53d1\u73b0\u7c7b\u4f3c\u7684\u9519\u8bef\uff0c\u518d\u8fdb\u884c\u5206\u6790\u3002\u4e0d\u8fc7\u8fd9\u63d0\u793a\u4e00\u70b9\uff0cOracle\u89c6\u56fe\u7684\u8fd4\u56de\u7ed3\u679c\u7ecf\u5e38\u4f5c\u4e3a\u6211\u4eec\u8bca\u65ad\u3001\u5206\u6790\u95ee\u9898\u7684\u4f9d\u636e\uff0c\u4f46\u662f\u5982\u679c\u7ed3\u679c\u672c\u8eab\u4e0d\u53ef\u4fe1\uff0c\u90a3\u4e48\u5728\u6b64\u57fa\u7840\u4e0a\u63a8\u5bfc\u51fa\u6765\u7684\u7ed3\u679c\u5f88\u53ef\u80fd\u4e5f\u662f\u4e0d\u53ef\u4fe1\u7684\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bb0\u5f55\u4e00\u4e2a\u5f88\u8be1\u5f02\u7684\u95ee\u9898\uff0c\u5728\u8fdb\u884c\u4e00\u4e2a\u6d4b\u8bd5\u65f6\u78b0\u5230\u7684\uff0cV$SESSION\u4e2d\u8bb0\u5f55\u7684BLOCKING_SESSION\u4fe1\u606f\u662f\u9519\u8bef\u7684\uff0c\u53ef\u60dc\u8fd9\u4e2a\u95ee\u9898\u5f53\u65f6\u6ca1\u6709\u6ce8\u610f\uff0c\u540e\u7eed\u4e5f\u65e0\u6cd5\u518d\u91cd\u73b0\u51fa\u6765\uff0c\u53ea\u597d\u4f5c\u4e3a\u4e00\u4e2a\u73b0\u8c61\u8bb0\u5f55\u4e00\u4e0b\uff0cOracle\u7ed9\u51fa\u7684\u4e00\u4e9b\u4fe1\u606f\u770b\u6765\u4e5f\u662f\u4e0d\u5b8c\u5168\u53ef\u4fe1\u7684\u3002 \u5728\u4f1a\u8bdd1\u6267\u884c\uff1a [tingkun.yang@node1 ~]$ sqlplus test\/test SQL*Plus: Release 10.2.0.5.0 &#8211; Production on Sun Nov 25 04:04:00 2012 Copyright (c) 1982, 2010, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 &#8211; 64bit Production With the Partitioning, &hellip; <a href=\"https:\/\/yangtingkun.net\/?p=1469\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[5],"tags":[1284,1283],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2yiY3-nH","_links":{"self":[{"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/posts\/1469"}],"collection":[{"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1469"}],"version-history":[{"count":1,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/posts\/1469\/revisions"}],"predecessor-version":[{"id":1470,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/posts\/1469\/revisions\/1470"}],"wp:attachment":[{"href":"https:\/\/yangtingkun.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}