Auto monitoring and logging of locks
Posted in 2009
Kamran asked whether IDS has DB2-style event monitors to automatically detect and log deadlocks/lock timeouts, and to alert when a session holds more than N locks. Jonathan Leffler said such automatic deadlock-detail logging and per-session lock limits have been requested but aren't implemented. For the immediate need (a session holding 69,190 locks), others suggested manual approaches: 'onstat -k' (mapping rstcb to the user, showing partnum/rowid/key for each lock) or querying sysmaster's syslocks in dirty read, grouped by tabname/type. No automated monitoring/alerting solution was found.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Transactions, Locking & Isolation
Hi, We have event monitors for deadlocks etc in DB2. Is there something like event monitor to detect and log the detail information about a deadlock or request timeout? can we generate alert for a session having more than N number of locks at an instance of time? regards, Kamran
KAMRAN HAQ wrote: > Hi, > We have event monitors for deadlocks etc in DB2. Is there something like event > monitor to detect and log the detail information about a deadlock or request > timeout? > can we generate alert for a session having more than N number of locks at an > instance of time? Why don't you just write your code properly? -- Cheers, Obnoxio The Clown http://obotheclown.blogspot.com -- This message has been scanned for viruses and dangerous content by OpenProtect(http://www.openprotect.com), and is believed to be clean.
On Thu, May 14, 2009 at 10:32, Obnoxio The Clown <obnoxio@serendipita.com> wrote: > KAMRAN HAQ wrote: >> We have event monitors for deadlocks etc in DB2. Is there something like event >> monitor to detect and log the detail information about a deadlock or request >> timeout? >> Can we generate alert for a session having more than N number of locks at an >> instance of time? > > Why don't you just write your code properly? Because it is hard to get right, you need help to get it right, and they probably don't write all the code using the database? It is a request that has been made before - to provide more information about the processes and locks involved in a deadlock (immediately before the deadlock is avoided). Similarly, there have been requests to put a limit on the number of locks a session may have, and reporting when a session breaches that limit is a logical extension. There are some minor complications - like should it report a single session twice, once when it reaches the limit and a second time when the locks reach a maximum (which is just before commit) or statement completion. It hasn't been implemented, AFAIK. I'm not sure whether OAT can help with this. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2008.0513 -- http://dbi.perl.org/ "Blessed are we who can laugh at ourselves, for we shall never cease to be amused." NB: Please do not use this email for correspondence. I don't necessarily read it every week, even. Vince Lombardi - "We didn't lose the game; we just ran out of time." - http://www.brainyquote.com/quotes/authors/v/vince_lombardi.html
Below are some details of a lock. There a session found acquiring 69190 locks.
Can we found what locks its holding like information about breakdown that how
many locks are on table1, table2 etc?
Is there a way to log the statements possesing locks on a certain object(row
or table) for more than N seconds?
-------------------------------------------------------------------------
# onstat -u
Userthreads
address flags sessid user tty wait tout locks nreads nwrites
13cad1a70 --BPX-- 38845 sysrport - 0 0 69190 118553 48308
# onstat -g ses 38845
IBM Informix Dynamic Server Version 11.50.FC3W1 -- On-Line (Prim) -- Up 7 days
23:55:59 -- 2683904 Kbytes
session effective #RSAM total used dynamic
id user user tty pid hostname threads memory memory explain
38845 sysrport - - -1 orgwapp2 1 540672 524560 off
tid name rstcb flags curstk status
35258 sqlexec 13cad1a70 --BPR-- 7839 running-
Memory pools count 3
name class addr totalsize freesize #allocfrag #freefrag
38845 V 13560c040 532480 11344 929 13
38845*O0 V 18ce78040 4096 808 1 1
38845_SORT_ V 192957040 12288 4568 34 4
name free used name free used
overhead 0 9864 mtmisc 0 440
scb 0 144 opentable 0 17992
filetable 0 3152 ru 0 624
log 0 16536 temprec 0 21664
keys 0 1440 ralloc 0 360080
gentcb 0 1760 ostcb 0 2872
sort 0 3168 sqscb 0 23848
sql 0 72 srtmembuf 0 640
rdahead 0 576 hashfiletab 0 552
osenv 0 2568 sqtcb 0 7616
fragman 0 52872 shmblklist 0 1336
udr 0 2480
sqscb info
scb sqscb optofc pdqpriority sqlstats optcompind directives
1a454a0c0 199f23028 0 0 0 2 1
Sess SQL Current Iso Lock SQL ISAM F.E.
Id Stmt type Database Lvl Mode ERR ERR Vers Explain
38845 INSERT tapis_1032 CR Not Wait 0 0 9.28 Off
Current SQL statement :
insert into nonfin_report_D values
(today,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
Host variables :
address type flags value
-----------------------------------------
0x00000001900d4038 CHAR 0x002
0x00000001900d40c8 CHAR 0x002
0x00000001900d4158 CHAR 0x002
0x00000001900d41e8 CHAR 0x002
0x00000001900d4278 CHAR 0x002
0x00000001900d4308 CHAR 0x002
0x00000001900d4398 CHAR 0x002
0x00000001900d4428 CHAR 0x002
0x00000001900d44b8 CHAR 0x002
0x00000001900d4548 CHAR 0x002
0x00000001900d45d8 CHAR 0x002
0x00000001900d4668 CHAR 0x002
0x00000001900d46f8 CHAR 0x002
0x00000001900d4788 CHAR 0x002
0x00000001900d4818 CHAR 0x002
0x00000001900d48a8 CHAR 0x002
0x00000001900d4938 CHAR 0x002
0x00000001900d49c8 CHAR 0x002
0x00000001900d4a58 CHAR 0x002
0x00000001900d4ae8 CHAR 0x002
0x00000001900d4b78 CHAR 0x002
0x00000001900d4c08 CHAR 0x002
Last parsed SQL statement :
insert into nonfin_report_D values
(today,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
# onstat -g stm 38845
IBM Informix Dynamic Server Version 11.50.FC3W1 -- On-Line (Prim) -- Up 7 days
23:56:55 -- 2683904 Kbytes
session 38845 ---------------------------------------------------------------sdblock heapsz statement ('*' = Open cursor)
1a633f028 153128 *select t.tapi_no, created_on,
expiry_on,get_ch_id_code(c.tapi_no) ch_id_code, get_ch_id_code_val(c.tapi_no)
ch_id_code_val, first_name1,last_name1,address1,address2, t.city,
state_code,zip_postal_code,cc.country_code2,replace(home_phone_no,'-','')
home_phone_no, work_phone_no, sc.tapi_status_pos tapi_status_pos,
replace(sc.ledger_balance||' ','-','') tapi_balance
,decode(substr(sc.ledger_balance||' ',1,1),'-','-','+') Balance_Sign,
p.tapi_prg_id, '' sub_prog_id_val,c.date_of_birth, p.fin || substr (c.tapi_no,
7, length(c.tapi_no) ) pseudo_dda_no from tapi_events p, sumd_tapi_funds
sc,tapis c ,outer country_codes cc where t.country_code=cc.country_code and
t.tapi_prg_id = p.tapi_prg_id and sc.tapi_no = t.tapi_no and sc.sum_date =
today -1 and not (sc.tapi_status_pos='A' and sc.ledger_balance=0 and
(c.last_update_on != TODAY -1 AND t.last_act_on != TODAY -1 AND
t.last_sts_chg_on != TODAY -1 )) order by 1 desc, 2 asc
1a633f240 58872 <SPL statement>
1a633f458 99696 <SPL statement>
1a633f670 9856 insert into nonfin_report_D values
(today,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
-------------------------------------------------------------------------
Hi,
you can run
onstat -k (gives partition IDs of locks for all sessions)
or
dbaccess sysmaster << eof
set isolation dirty read ;
select tabname,type,count(*) from syslocks where owner = <SESSION_ID> group by
1,2;eof
-------------------------------------------
SPAR Österreichische Warenhandels-AG
Hauptzentrale
A - 5015 Salzburg, Europastrasse 3
FN 34170 a
Tel: +43 662 4470 24223
Mobile: +43 664 6259575
E-Mail: Andreas.KUTSCHE@spar.at
Internet: http://www.spar.at
Wichtiger Hinweis: Der Inhalt dieser E-Mail kann vertrauliche und rechtlich
geschützte Informationen, insbesondere Betriebs- oder Geschäftsgeheimnisse,
enthalten, zu deren Geheimhaltung der Empfänger verpflichtet ist. Die
Informationen in dieser E-Mail sind ausschließlich für den Adressaten
bestimmt. Sollten Sie die E-Mail irrtümlich erhalten haben so ersuchen wir
Sie, die Nachricht von Ihrem System zu löschen und sich mit uns in Verbindung
zu setzen.
Über das Internet versandte E-Mails können leicht manipuliert oder unter
fremdem Namen erstellt werden. Daher schließen wir die rechtliche
Verbindlichkeit der in dieser Nachricht enthaltenen Informationen aus. Der
Inhalt der E-Mail ist nur rechtsverbindlich, wenn er von uns schriftlich
bestätigt und gezeichnet wird.
Sollte trotz der von uns verwendeten Virus-Schutzprogramme durch die Zusendung
von E-Mails ein Virus in Ihre Systeme gelangen, haften wir nicht für evtl.
hieraus entstehende Schäden.
Wir danken für Ihr Verständnis.
Important notice: The contents of this e-mail may contain confidential and
legally protected information that is in particular related to operational and
trade secrets, which the recipient is obliged to treat as confidential. The
information in this e-mail is made available exclusively for use by the
addressee. In the event that the e-mail may have been sent to you in error, we
would ask you to kindly delete this communication from your system and to
contact us.
E-mails sent via the Internet can be easily manipulated or sent out under
someone else's name. We therefore do not accept legal liability for the
information contained in this communication. The contents of the e-mail are
only legally binding if they have been confirmed and signed by us in writing.
If, in spite of our using Antivirus protection software, a virus may have
penetrated your system through the sending of this e-mail, we do not accept
liability for any damage that may possibly arise as a result of this.
We trust that you appreciate our position.
-------------------------------------------
-----Ursprüngliche Nachricht-----
Von: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] Im Auftrag von KAMRAN
HAQ
Gesendet: Freitag, 15. Mai 2009 13:56
An: ids@iiug.org
Betreff: Re: Auto monitoring and logging of locks [15782]
Below are some details of a lock. There a session found acquiring 69190 locks.
Can we found what locks its holding like information about breakdown that how
many locks are on table1, table2 etc?
Is there a way to log the statements possesing locks on a certain object(row
or table) for more than N seconds?
-------------------------------------------------------------------------
# onstat -u
Userthreads
address flags sessid user tty wait tout locks nreads nwrites
13cad1a70 --BPX-- 38845 sysrport - 0 0 69190 118553 48308
# onstat -g ses 38845
IBM Informix Dynamic Server Version 11.50.FC3W1 -- On-Line (Prim) -- Up 7 days
23:55:59 -- 2683904 Kbytes
session effective #RSAM total used dynamic
id user user tty pid hostname threads memory memory explain
38845 sysrport - - -1 orgwapp2 1 540672 524560 off
tid name rstcb flags curstk status
35258 sqlexec 13cad1a70 --BPR-- 7839 running-
Memory pools count 3
name class addr totalsize freesize #allocfrag #freefrag
38845 V 13560c040 532480 11344 929 13
38845*O0 V 18ce78040 4096 808 1 1
38845_SORT_ V 192957040 12288 4568 34 4
name free used name free used
overhead 0 9864 mtmisc 0 440
scb 0 144 opentable 0 17992
filetable 0 3152 ru 0 624
log 0 16536 temprec 0 21664
keys 0 1440 ralloc 0 360080
gentcb 0 1760 ostcb 0 2872
sort 0 3168 sqscb 0 23848
sql 0 72 srtmembuf 0 640
rdahead 0 576 hashfiletab 0 552
osenv 0 2568 sqtcb 0 7616
fragman 0 52872 shmblklist 0 1336
udr 0 2480
sqscb info
scb sqscb optofc pdqpriority sqlstats optcompind directives
1a454a0c0 199f23028 0 0 0 2 1
Sess SQL Current Iso Lock SQL ISAM F.E.
Id Stmt type Database Lvl Mode ERR ERR Vers Explain
38845 INSERT tapis_1032 CR Not Wait 0 0 9.28 Off
Current SQL statement :
insert into nonfin_report_D values
(today,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
Host variables :
address type flags value
-----------------------------------------
0x00000001900d4038 CHAR 0x002
0x00000001900d40c8 CHAR 0x002
0x00000001900d4158 CHAR 0x002
0x00000001900d41e8 CHAR 0x002
0x00000001900d4278 CHAR 0x002
0x00000001900d4308 CHAR 0x002
0x00000001900d4398 CHAR 0x002
0x00000001900d4428 CHAR 0x002
0x00000001900d44b8 CHAR 0x002
0x00000001900d4548 CHAR 0x002
0x00000001900d45d8 CHAR 0x002
0x00000001900d4668 CHAR 0x002
0x00000001900d46f8 CHAR 0x002
0x00000001900d4788 CHAR 0x002
0x00000001900d4818 CHAR 0x002
0x00000001900d48a8 CHAR 0x002
0x00000001900d4938 CHAR 0x002
0x00000001900d49c8 CHAR 0x002
0x00000001900d4a58 CHAR 0x002
0x00000001900d4ae8 CHAR 0x002
0x00000001900d4b78 CHAR 0x002
0x00000001900d4c08 CHAR 0x002
Last parsed SQL statement :
insert into nonfin_report_D values
(today,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
# onstat -g stm 38845
IBM Informix Dynamic Server Version 11.50.FC3W1 -- On-Line (Prim) -- Up 7 days
23:56:55 -- 2683904 Kbytes
session 38845 ---------------------------------------------------------------sdblock heapsz statement ('*' = Open cursor)
1a633f028 153128 *select t.tapi_no, created_on,
expiry_on,get_ch_id_code(c.tapi_no) ch_id_code, get_ch_id_code_val(c.tapi_no)
ch_id_code_val, first_name1,last_name1,address1,address2, t.city,
state_code,zip_postal_code,cc.country_code2,replace(home_phone_no,'-','')
home_phone_no, work_phone_no, sc.tapi_status_pos tapi_status_pos,
replace(sc.ledger_balance||' ','-','') tapi_balance
,decode(substr(sc.ledger_balance||' ',1,1),'-','-','+') Balance_Sign,
p.tapi_prg_id, '' sub_prog_id_val,c.date_of_birth, p.fin || substr (c.tapi_no,
7, length(c.tapi_no) ) pseudo_dda_no from tapi_events p, sumd_tapi_funds
sc,tapis c ,outer country_codes cc where t.country_code=cc.country_code and
t.tapi_prg_id = p.tapi_prg_id and sc.tapi_no = t.tapi_no and sc.sum_date =
today -1 and not (sc.tapi_status_pos='A' and sc.ledger_balance=0 and
(c.last_update_on != TODAY -1 AND t.last_act_on != TODAY -1 AND
t.last_sts_chg_on != TODAY -1 )) order by 1 desc, 2 asc
1a633f240 58872 <SPL statement>
1a633f458 99696 <SPL statement>
1a633f670 9856 insert into nonfin_report_D values
(today,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)@
onstat -k and map the rstcd to the user. The partnum and rowid's of alllocked rows and partnum and key of all locked keys will be there.
Art
Art S. Kagel
Oninit (www.oninit.com)
IIUG Board of Directors (art@iiug.org)
Disclaimer: Please keep in mind that my own opinions are my own opinions and
do not reflect on my employer, Oninit, the IIUG, nor any other organization
with which I am associated either explicitly or implicitly. Neither do
those opinions reflect those of other individuals affiliated with any entity
with which I am affiliated nor those of the entities themselves.
On Fri, May 15, 2009 at 7:55 AM, KAMRAN HAQ <khaq@i2cinc.com> wrote:
> Below are some details of a lock. There a session found acquiring 69190
> locks.
> Can we found what locks its holding like information about breakdown that
> how
> many locks are on table1, table2 etc?
> Is there a way to log the statements possesing locks on a certain
> object(row
> or table) for more than N seconds?
>
> -------------------------------------------------------------------------
> # onstat -u>
> Userthreads
> address flags sessid user tty wait tout locks nreads nwrites
>
> 13cad1a70 --BPX-- 38845 sysrport - 0 0 69190 118553 48308
>
> # onstat -g ses 38845>
> IBM Informix Dynamic Server Version 11.50.FC3W1 -- On-Line (Prim) -- Up 7> days
> 23:55:59 -- 2683904 Kbytes
>
> session effective #RSAM total used dynamic
> id user user tty pid hostname threads memory memory explain
>
> 38845 sysrport - - -1 orgwapp2 1 540672 524560 off
>
> tid name rstcb flags curstk status
>
> 35258 sqlexec 13cad1a70 --BPR-- 7839 running-
>
> Memory pools count 3
>
> name class addr totalsize freesize #allocfrag #freefrag
>
> 38845 V 13560c040 532480 11344 929 13
> 38845*O0 V 18ce78040 4096 808 1 1
> 38845_SORT_ V 192957040 12288 4568 34 4
>
> name free used name free used
> overhead 0 9864 mtmisc 0 440
> scb 0 144 opentable 0 17992
> filetable 0 3152 ru 0 624
> log 0 16536 temprec 0 21664
> keys 0 1440 ralloc 0 360080
> gentcb 0 1760 ostcb 0 2872
> sort 0 3168 sqscb 0 23848
> sql 0 72 srtmembuf 0 640
> rdahead 0 576 hashfiletab 0 552
> osenv 0 2568 sqtcb 0 7616
> fragman 0 52872 shmblklist 0 1336
> udr 0 2480
>
> sqscb info
> scb sqscb optofc pdqpriority sqlstats optcompind directives
>
> 1a454a0c0 199f23028 0 0 0 2 1
>
> Sess SQL Current Iso Lock SQL ISAM F.E.
> Id Stmt type Database Lvl Mode ERR ERR Vers Explain
>
> 38845 INSERT tapis_1032 CR Not Wait 0 0 9.28 Off
>
> Current SQL statement :
>
> insert into nonfin_report_D values>
> (today,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
>
> Host variables :
>
> address type flags value
>
> -----------------------------------------
>
> 0x00000001900d4038 CHAR 0x002
>
> 0x00000001900d40c8 CHAR 0x002
>
> 0x00000001900d4158 CHAR 0x002
>
> 0x00000001900d41e8 CHAR 0x002
>
> 0x00000001900d4278 CHAR 0x002
>
> 0x00000001900d4308 CHAR 0x002
>
> 0x00000001900d4398 CHAR 0x002
>
> 0x00000001900d4428 CHAR 0x002
>
> 0x00000001900d44b8 CHAR 0x002
>
> 0x00000001900d4548 CHAR 0x002
>
> 0x00000001900d45d8 CHAR 0x002
>
> 0x00000001900d4668 CHAR 0x002
>
> 0x00000001900d46f8 CHAR 0x002
>
> 0x00000001900d4788 CHAR 0x002
>
> 0x00000001900d4818 CHAR 0x002
>
> 0x00000001900d48a8 CHAR 0x002
>
> 0x00000001900d4938 CHAR 0x002
>
> 0x00000001900d49c8 CHAR 0x002
>
> 0x00000001900d4a58 CHAR 0x002
>
> 0x00000001900d4ae8 CHAR 0x002
>
> 0x00000001900d4b78 CHAR 0x002
>
> 0x00000001900d4c08 CHAR 0x002
>
> Last parsed SQL statement :
>
> insert into nonfin_report_D values>
> (today,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
>
> # onstat -g stm 38845>
> IBM Informix Dynamic Server Version 11.50.FC3W1 -- On-Line (Prim) -- Up 7> days
> 23:56:55 -- 2683904 Kbytes
>
> session 38845
> ---------------------------------------------------------------
> sdblock heapsz statement ('*' = Open cursor)
>
> 1a633f028 153128 *select t.tapi_no, created_on,
> expiry_on,get_ch_id_code(c.tapi_no) ch_id_code,
> get_ch_id_code_val(c.tapi_no)
> ch_id_code_val, first_name1,last_name1,address1,address2, t.city,
> state_code,zip_postal_code,cc.country_code2,replace(home_phone_no,'-','')
> home_phone_no, work_phone_no, sc.tapi_status_pos tapi_status_pos,
> replace(sc.ledger_balance||' ','-','') tapi_balance
> ,decode(substr(sc.ledger_balance||' ',1,1),'-','-','+') Balance_Sign,
> p.tapi_prg_id, '' sub_prog_id_val,c.date_of_birth, p.fin || substr
> (c.tapi_no,
> 7, length(c.tapi_no) ) pseudo_dda_no from tapi_events p, sumd_tapi_funds
> sc,tapis c ,outer country_codes cc where t.country_code=cc.country_code and
> t.tapi_prg_id = p.tapi_prg_id and sc.tapi_no = t.tapi_no and sc.sum_date =
> today -1 and not (sc.tapi_status_pos='A' and sc.ledger_balance=0 and
> (c.last_update_on != TODAY -1 AND t.last_act_on != TODAY -1 AND
> t.last_sts_chg_on != TODAY -1 )) order by 1 desc, 2 asc
>
> 1a633f240 58872 <SPL statement>
> 1a633f458 99696 <SPL statement>
> 1a633f670 9856 insert into nonfin_report_D values
> (today,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
> -------------------------------------------------------------------------
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--001636c5abcc7d14870469f36ee1