If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Insert statement getting stuck randomly in DB2 stored procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-17-11, 15:18
shuchi_mishra shuchi_mishra is offline
Registered User
 
Join Date: Nov 2011
Posts: 4
Question Insert statement getting stuck randomly in DB2 stored procedure

We are running OLTP transactions on DB2 9.5 on Sun solaris server.Oddly, during November-December every year(during peak workload), a stored procedure gets stuck at a single insert statement randomly.The same procedure works fine on killing the application id and manually running the same procedure.The stored procedure runs fine for remaining year without any intervention.
The stored procedure stucks while processing data of Walmart only while other accounts(like Best Buy etc.) runs fine.Here is the SQL where it gets stucks:

INSERT INTO VMIITEMLOCMASTER
( CUSTOMERCODE, LOCATIONCODE, PRODUCTCODE, SKU, STATUSCODE, EFFSTARTDATE, EFFENDDATE,
NEWRELEASEDATE, CATALOGSTARTDATE, CATALOGENDDATE, STREETDATE, MSRP, CAPACITY, MINCAPACITY, SAFETYSTOCK,
NETCHANGEFLAG, EXTRACTFLAG, CREATED, UPDATED, POG_COMMITDATE, CREATEDBY, FACING,
PARENTCODE, COMPONENTCAP, COMPONENTFLAG, COMPONENTQTY, BOMCODE, SEARCH_GRP, QUANTITYONHAND
)
SELECT CUSTOMERCODE, LOCATIONCODE, PRODUCTCODE, SKU, STATUSCODE,
COALESCE (EFFSTARTDATE, CAST ('01/01/1901' AS DATE)),
COALESCE (EFFENDDATE, CAST ('01/01/1901' AS DATE)),
NEWRELEASEDATE, CATALOGSTARTDATE, CATALOGENDDATE, STREETDATE, MSRP, CAPACITY, COALESCE (MINCAPACITY,0), SAFETYSTOCK,
NETCHANGEFLAG, 'Y', CURRENT DATE, CURRENT DATE, CURRENT DATE, 'DFUEXTRACT',FACING,
PARENTCODE, COMPONENTCAP, COMPONENTFLAG, COMPONENTQTY, BOMCODE, SUBSTR(PRODUCTCODE, 1, 3), 0
FROM HISTPOGITEMLOCMASTER
WHERE SEQ = :HV00033 :HI00033
AND CUSTOMERCODE = :HV00009 :HI00009
EXCEPT
SELECT P.CUSTOMERCODE, P.LOCATIONCODE, P.PRODUCTCODE, P.SKU, P.STATUSCODE,
COALESCE (P.EFFSTARTDATE, CAST ('01/01/1901' AS DATE)),
COALESCE (P.EFFENDDATE , CAST ('01/01/1901' AS DATE)), P.NEWRELEASEDATE,
P.CATALOGSTARTDATE, P.CATALOGENDDATE, P.STREETDATE, P.MSRP, COALESCE(P.CAPACITY, 0), COALESCE(P.MINCAPACITY, 0), P.SAFETYSTOCK,
P.NETCHANGEFLAG, 'Y', CURRENT DATE, CURRENT DATE, CURRENT DATE, 'DFUEXTRACT', P.FACING,
P.PARENTCODE, P.COMPONENTCAP, P.COMPONENTFLAG, P.COMPONENTQTY, P.BOMCODE, SUBSTR(P.PRODUCTCODE, 1, 3), 0
FROM HISTPOGITEMLOCMASTER P, VMIITEMLOCMASTER M
WHERE M.CUSTOMERCODE = :HV00009 :HI00009
AND P.SEQ = :HV00033 :HI00033
AND P.CUSTOMERCODE = :HV00009 :HI00009
AND P.CUSTOMERCODE = M.CUSTOMERCODE
AND P.LOCATIONCODE = M.LOCATIONCODE
AND P.PRODUCTCODE = M.PRODUCTCODE WITH UR


I have very limited knowledge to trouble shoot this issue.Any help would be greatly appreciated.
Reply With Quote
  #2 (permalink)  
Old 11-17-11, 15:24
shuchi_mishra shuchi_mishra is offline
Registered User
 
Join Date: Nov 2011
Posts: 4
Insert statement getting stuck in DB2 9.5 Stored procedure

Please find the snapshot attached.Please try to open it in wordpad,editplus,textpad for legible format
Attached Files
File Type: txt snapshot.txt (17.2 KB, 2 views)
Reply With Quote
  #3 (permalink)  
Old 11-17-11, 15:30
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Check the LOCKTIMEOUT parm in the db cfg (db2 get db cfg for db-name). If it is set to -1 then you have infinite lock wait time and will not receive a -911 when there is lock contention and your SQL may hang. You may want to change that to 30 seconds to force locktimeout errors.

Another issue is that you may have some insert latency when log files are full or log buffer is full. I would make your log file size at least 10000 pages, maybe more. Increase LOGBUFFSZ to 256.

Also look at your page cleaning. This includes number of page cleaners (make sure it is set to automatic) and page cleaning threashold (lower this to about 20% or better yet set the environment variable as follows: db2set DB2_USE_ALTERNATE_PAGE_CLEANING=ON).
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #4 (permalink)  
Old 11-17-11, 15:33
shuchi_mishra shuchi_mishra is offline
Registered User
 
Join Date: Nov 2011
Posts: 4
Question Insert statement getting stuck randomly in DB2 stored procedure

Please find the database and database manager configuration file attached.
Attached Files
File Type: txt db_cfg.txt (7.3 KB, 2 views)
File Type: txt DBM_CFG.txt (5.2 KB, 1 views)
Reply With Quote
  #5 (permalink)  
Old 11-17-11, 15:41
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Based on your db config (LOCKTIMEOUT -1), looks like it could be hung on a lock wait. LOGBUFSZ seems a bit large, but maybe OK.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390

Last edited by Marcus_A; 11-17-11 at 15:45.
Reply With Quote
  #6 (permalink)  
Old 11-17-11, 15:48
shuchi_mishra shuchi_mishra is offline
Registered User
 
Join Date: Nov 2011
Posts: 4
Question Insert statement getting stuck randomly in DB2 stored procedure

Hi Marcus,

Many thanks for the reply.The log file size in database is set to 65536 pages(4KB each) and LOGBUFSZ is 1536 pages(4 KB each).

Moreover, the page cleaners are set automatic and page cleaning threshold is already 5%
The environment variable DB2_USE_ALTERNATE_PAGE_CLEANING is also set as ON.

I am not sure about impact to other procedures by changing locktimeout value from -1 to something else.So, I'll refrain myself from setting it to some other value for now . I am attaching the screenshot of db2top captured during issue to give you better idea of locks contention.

Please advise if you notice anything else.
Attached Files
File Type: doc db2top-screenshot of memory utilization.doc (247.0 KB, 3 views)
Reply With Quote
  #7 (permalink)  
Old 11-17-11, 16:15
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
I noticed 15 deadlocks in the db2top report, so you may have some kind of lock contention. With LOCKTIMEOUT -1, lockwaits (that are not deadlocked) will wait indefinitely if needed until resource requested is available.

Also could be automatic resize of tablespace, if increment is large.

The LOGBUFSZ of 1536 is probably too large IMO, unless you have a lot of LOB's that are logged.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On