Monday, September 27, 2010

Dead Lock

The server run over the weekend, on Monday morning it appeared not working any more as the log shown. My first impression is the process has exited, but why there is no error reported in log. I checked Task Manager, there were two java processes Id, then I looked at Process Explorer, from tree view, it shows one is parent, the other is child which is the one I am interested. So the process is still alive, why doesn't it work then? I used JDK's tool 'jstack' to print out all the thread stacks associate with this child process Id. At the end of the output, it displayed a dead lock have been detected.

Found one Java-level deadlock:
=============================
"Timer-2":
waiting to lock monitor 0x4734334c (object 0x079cd3b8, a com.xyz.PunaAdapter), which is held by "Timer-1"
"Timer-1":
waiting to lock monitor 0x475a397c (object 0x0a946f60, a com.xyz.SgeSessionManager),which is held by "Timer-2"

Friday, September 24, 2010

I wonder for a while


Criteria crit = getSession().createCriteria(ApSummary.class)
.add(Restrictions.eq("controller.id", controllerId));

This "controller.id" surprises me a bit since when we do a join in Criteria query, generally we have to use createAlias() such as:

Criteria crit = getSession().createCriteria(ApSummary.class)
.createAlias("controller", "hwc").add(Restrictions.eq("hwc.id", controllerId));

The trick here is that controllre.id would be SMARTLY interpreted as column "controllerId" in ApSummary without doing the extra join!