Simple awk script to print blocked threads

Yet another variation on this theme. This is good because it will allow you to quickly go to the problem thread.

#!/bin/awk -f

{
  if ($0 ~ "- locked" || $0 ~ "- waiting to lock") {
    s[i++]=$0
  }
}
END {
  for (i in s) {
    if (s[i] ~ "waiting to lock") {
      split(s[i],t)
      for (j in s) {
        split(s[j],u)
        if (s[j] ~ "- locked" && u[3] ~ t[5]) {
          print u[3],u[5]," is blocking ",t[7]
          break
        }
      }
    }
  }
}
bash-4.1$ awk -f ~/blocked.awk *1746* | sort | uniq -c | sort -nr | head -5
    283 <0x0000000766283810> atg.adapter.gsa.GSAItem)  is blocking  atg.adapter.gsa.GSAItem)
     43 <0x000000063cbfad60> atg.adapter.gsa.GSAItemDescriptor)  is blocking  atg.adapter.gsa.GSAItemDescriptor)
     11 <0x000000064c282cf8> com.express.commerce.order.ExpressOrderHolder$$EnhancerBySpringCGLIB$$27225c0d)  is blocking  com.express.commerce.order.ExpressOrderHolder$$EnhancerBySpringCGLIB$$27225c0d)
      4 <0x00000006631b15a8> com.express.commerce.order.ExpressOrderImpl)  is blocking  com.express.commerce.order.ExpressOrderImpl)
      3 <0x00000007ab9f9670> com.express.commerce.order.ExpressOrderImpl)  is blocking  com.express.commerce.order.ExpressOrderImpl)
bash-4.1$

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.