You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Dirk Kessler <di...@vontu.com> on 2004/08/11 00:37:05 UTC
ODMG Lock strategy classes retry indefinitely (OJB1.0rc7)
Why do the various lock strategy classes in the
org.apache.ojb.odmg.locking package retry locking after they fail to
acquire a lock (shouldn't they just return false?).
e.g.
from org.apache.ojb.odmg.locking.ReadCommitedStrategy
public boolean writeLock(TransactionImpl tx, Object obj)
{
LockEntry writer = getWriter(obj);
// if there is no writer yet we can try to get the global write
lock
if (writer == null)
{
// if lock could be acquired return true
if (setWriter(tx, obj))
return true;
// else try again
else
return writeLock(tx, obj);
}
if (writer.isOwnedBy(tx))
{
return true; // If I'm the writer, then I can write.
}
return false;
}
Why is "writeLock" called again when "setWriter" returns false?
Shouldn't this method just return false in that case (i.e. could not get
a lock on the object)? This method will execute indefinitely when
"setWriter" always returns false (E.G. possibly due to some system
failure). I encountered this "endless loop" behavior when using the
LockServlet and Tomcat is shutdown before the OJB client. This causes
the "setWriter" to fail permanently and "writeLock" is called
recursively until the application runs out of stack space.
Any information on this problem would be greatly appreciated.
Thanks,
-Dirk