
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2014 05:53 AM
This is question related to transactions which for some reason gets stuck and runs in the background utilizing system resources and slowing the instance down....
Whenever the instance is slow, i tend to check "All Active Transactions" menu and manually kill the transaction (ofcourse on the Developement instance)....
But I am just curious if anybody has some automated script or something that we can use to kill the long running transaction rather than manually going to the menu and killing it ....
Solved! Go to Solution.
- Labels:
-
Performance Analytics

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015 06:46 AM
Actually I created a UI page for this and have it on my home page on our development instance ... You have a script and a UI page in this ... Hope this helps ...
Script include:
var ScriptUtils= Class.create();
ScriptUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
killOldTransactions : function(){
try
{
var transactionCount = 0;
var getTransaction = new GlideRecord('v_transaction');
getTransaction.addEncodedQuery("age>javascript:gs.getDurationDate('0 0:10:0')");
getTransaction.query();
while(getTransaction.next()) {
transactionCount++;
GlideTransactionManager.kill(getTransaction.session_id.toString());
}
if(transactionCount == 0)
{
return 'No Transaction Were Cancelled';
}
else
{
return transactionCount + ' Transactions were cancelled';
}
}
catch(err)
{
return 'Error While Cancelling Transaction-'+err;
}
}
});
Ui page:
HTML:
<html>
<head>
</head>
<body>
<TABLE>
<TR>
<TD colspan='2' align="center"><input type="button" value="Cancel" onclick="cancelTransaction()"/> </TD>
</TR>
</TABLE>
</body>
</html>
Client Script of UI page:
function cancelTransaction(){
var cancelTrasaction = new GlideAjax("ScriptUtils");
cancelTrasaction.addParam('sysparm_name','killOldTransactions');
cancelTrasaction.getXMLWait();
alert(cancelTrasaction.getAnswer());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2014 06:47 AM
I am not sure if I would want to automate this type of activity. There needs to be some kind of manual review and analysis in place before we kill a transaction. Just my opinion

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2014 07:44 AM
agree.. but I need this only for development instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2014 12:30 PM
i managed to write a simple script and reused the code of kill button ..... will post the solution later once I get time...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015 06:00 AM
Could you share that please?:)
I am just in the process of running some background scripts which clean the cmdb_rel_ci table and the are taking quite a while (considering my table has over 2 million records in it)...
Thanks in advance!