Vous êtes sur la page 1sur 2

********************************************************************************

********************************************************************************
*************
Log Usage and identification of application holding maximum or oldest log, using
snapshots: Transaction log Full error SQL0964C
1)run below command, to get application handle of application holding oldest log
, and other log usage details,
db2 get snapshot for database on testdb|grep -e 'Log space available to the da
tabase (Bytes)' -e 'Log space used by the database (Bytes)' -e 'Maximum secondar
y log space used (Bytes)' -e 'Maximum total log space used (Bytes)' -e 'Secondar
y logs allocated currently' -e 'Appl id holding the oldest transaction' -e 'File
number of first active log' -e 'File number of last active log' -e 'File number
of current active log' -e 'File number of log being archived'
this will give an output like,

Log space available to the database (Bytes)= 41990911
Log space used by the database (Bytes) = 24790273
Maximum secondary log space used (Bytes) = 7675688
Maximum total log space used (Bytes) = 24790273
Secondary logs allocated currently = 3
Appl id holding the oldest transaction = 113 .......................Appl id
holding oldest log(this feild is visible only if any thread is actually holding
old log)
File number of first active log = 227
File number of last active log = 233
File number of current active log = 231
File number of log being archived = Not applicable
Now we can do another snapshot to get details of this appl id, using below comma
nd,
db2 get snapshot for application agentid appl-id
In this case, db2 get snapshot for application agentid 113
To get appl-id alone, use
db2 get snapshot for database on dbname|grep -e 'Appl id holding the oldest tran
saction'|awk '{print $8}'
From this we can see many useful information, such as dyanmic sql,connection id,
agent status
Now if this application is to be cancelled, use below command,
db2 force application (APPL_HDL)
In our case, it will be db2 force application (113)
In case it's a SAP application, track to which application and user is responsib
le for this, by comparing the client_pid to SM66 and SM50 data.
If the application can be found, you can then discuss with the responsible user
to see whether commit or rollback should be issued.If you can not find the appli
cation process by identified process PID, that is, the client has passed away. S
o the corresponding DB2 agent should already either commit or rollback, but actu
ally not. Normally in this situation, you are hitting some bug; you should open
an OSS ticket in BC-DB-DB6 component in SAP Service Marketplace.
After this force application.
#Please do NOT kill db2agent using operating system commands. If do this, most p
robably you will crash the DB2 instance.
sample script to perform same task(provide database name as input)
################################################################################
###################################
#!/bin/sh
db2 connect to $1
a=`db2 get snapshot for database on $1 | grep -e 'Appl id holding the oldest tra
nsaction' | awk '{print $8}'`
echo "Cancelling Application id $a holding oldest log in database $1"
db2 "force application ($a)"
db2 connect reset
exit
################################################################################
#####################################
To get log usage of all applications, use below command,
db2 get snapshot for applications on testdb|grep -e 'Application handle' -e 'Pro
cess ID of client application' -e 'Coordinator agent process or thread ID' -e 'U
OW log space used (Bytes)'
********************************************************************************
********************************************************************************
****************

Vous aimerez peut-être aussi