V Cluster Transactions giving inconsistent results on querying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 12:15 PM
I'm trying to get active cluster transactions to identify the long running jobs.
Below is the script that I'm using after referring to the 'refresh' UI action as well as some community posts & KB articles.
Below function is to populate the transaction table:
refreshTrans: function() { //to mimic the refresh ui action through script
var vct = new VClusterTransaction('v_cluster_transaction');
vct.deleteTransactions();
var id = vct.informOtherNodes();
vct.refreshTransactions(GlideSession.get().getSessionID());
return GlideSession.get().getSessionID();
},
& Below one is to fetch the records:
getActiveTrans: function(str, count) {
str += 'Long Running Transactions:<br/>';
var lngTrscn = new GlideRecord('v_cluster_transaction');
lngTrscn.addQuery("age>javascript:gs.getDurationDate('0 1:0:0')");
lngTrscn.query();
while (lngTrscn.next()) {
str += count + ')Node id: ' + lngTrscn.node_id + '<br/>' + '   Age: ' + lngTrscn.getDisplayValue('age') + '<br/>' + '   URL: ' + lngTrscn.url + '<br/>';// pl ignore the   & br tags these are used purposefully & should not affect the output
count += 1;
}
return str;
},
I've tried using this in flow designer as well as scheduled job by giving around 5 mins of delay between the 2 functions. (Tried to range the delay from 30 secs to 5 mins)
I'm getting the output, however it's inconsistent. I sometimes get the correct result, sometimes get blank response while sometimes receive incorrect age(probably old record).
Can someone suggest what can I do here to achieve consistent output. Or is there any other way to get the current data from the 'v_cluster_transaction' table?
Thanks in advance!
Nikita Kale