{"id":485,"date":"2009-10-28T02:36:42","date_gmt":"2009-10-27T20:36:42","guid":{"rendered":"http:\/\/techsatwork.com\/blog\/?p=485"},"modified":"2016-01-07T11:31:11","modified_gmt":"2016-01-07T05:31:11","slug":"finding-lock-waits-in-db2","status":"publish","type":"post","link":"https:\/\/techsatwork.com\/?p=485","title":{"rendered":"Finding Lock waits in DB2"},"content":{"rendered":"<p>DB2 is \u00c2\u00a0a little tough on its locking mechanism. \u00c2\u00a0IBM says \u00c2\u00a0DB2 V9.7 has improved a lot on this area, I haven&#8217;t had a chance to test it rigorously , so I have to take the word for it.<\/p>\n<p>With DB2 V9.5 and lower,\u00c2\u00a0I have experienced lot of \u00c2\u00a0application on lock wait on NS and S locks. This has been frustrating when there are application that just wont release the locks from a reads and other application would require an X lock.\u00c2\u00a0\u00c2\u00a0 I wrote a script that will take a snapshot on lock waits everytime is run and also will notify (email or page) when an application is on lock wait for more than 5 minutes.<\/p>\n<p>You need to create a table to store the snapshot information\u00c2\u00a0 that can be used for investigative purpose.\u00c2\u00a0 The DDL for the table is as follows ;<\/p>\n<p>create table dba.snap_lockwait<br \/>\n(<br \/>\nSNAPSHOT_TIMESTAMP\u00c2\u00a0 TIMESTAMP,<br \/>\nDB_NAME\u00c2\u00a0 VARCHAR (128) ,<br \/>\nAGENT_ID bigint,<br \/>\nAPPL_NAME varchar(256)\u00c2\u00a0 ,<br \/>\nAUTHID VARCHAR (128),<br \/>\nTBSP_NAME VARCHAR (128),<br \/>\nTABSCHEMA\u00c2\u00a0\u00c2\u00a0 VARCHAR (128),<br \/>\nTABNAME\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 VARCHAR (128),<br \/>\nSUBSECTION_NUMBER\u00c2\u00a0\u00c2\u00a0 bigint,<br \/>\nLOCK_OBJECT_TYPE varchar(18),<br \/>\nLOCK_WAIT_START_TIME\u00c2\u00a0\u00c2\u00a0 TIMESTAMP ,<br \/>\nLOCK_NAME varchar(32),<br \/>\nLOCK_MODE\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 varchar(10),<br \/>\nLOCK_MODE_REQUESTED\u00c2\u00a0 varchar(10),<br \/>\nAGENT_ID_HOLDING_LK bigint,<br \/>\nAPPL_ID_HOLDING_LK\u00c2\u00a0 VARCHAR (128),<br \/>\nLOCK_ESCALATION\u00c2\u00a0 SMALLINT,<br \/>\nDBPARTITIONNUM\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 SMALLINT<br \/>\n)<\/p>\n<p>The script that does the job is \u00c2\u00a0<a href=\"https:\/\/techsatwork.com\/blog\/wp-content\/uploads\/2009\/10\/find_lockwait.txt\" target=\"_parent\">find_lockwait.txt<\/a> .\u00c2\u00a0\u00c2\u00a0 I have it running on a crontab every 2 mins.<\/p>\n<p>Like I always say,\u00c2\u00a0 ensure that the script is safe to run on your environment and use due dilegence.\u00c2\u00a0\u00c2\u00a0 If you have any comments or questions regarding this please let me know.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>DB2 is \u00c2\u00a0a little tough on its locking mechanism. \u00c2\u00a0IBM says \u00c2\u00a0DB2 V9.7 has improved a lot on this area, I haven&#8217;t had a chance to test it rigorously , so I have to take the word for it. With DB2 V9.5 and lower,\u00c2\u00a0I have experienced lot of \u00c2\u00a0application on lock wait on NS and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","site-transparent-header":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[3],"tags":[943,247,257,258],"class_list":["post-485","post","type-post","status-publish","format-standard","hentry","category-db2","tag-db2","tag-db2-lock","tag-lockwait","tag-snapshot-on-locks"],"_links":{"self":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=485"}],"version-history":[{"count":5,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/485\/revisions"}],"predecessor-version":[{"id":1527,"href":"https:\/\/techsatwork.com\/index.php?rest_route=\/wp\/v2\/posts\/485\/revisions\/1527"}],"wp:attachment":[{"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techsatwork.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}