On Sat, 17 Feb 2001, you wrote:
> Hi !!
> 
> We have a kind of strange problem with JBOSS 2.0 and LOCKING.
> 
> We haven't described any locking in our deployment descriptor, but sometimes
> we got a kind of
> deadlock situation.
> 
> The client application executes a call to a entity bean and it seems that it
> never returns from this call.
> When we look at the log files of jboss we see something like a LOCK WAITING
> message and it seems the
> client call never returns.
> 
> Which locking mechanism is used from jboss if htere is no locking specified
> at all.
> Is this a bug in Jboss.
> We are also not able to reproduce the bug, it happens sometimes.
> 
> Any suggestions ?

Yep, sounds like deadlock to me.  Look for cases where a client calls a method
on bean A which calls a method on bean B which calls another method on bean A. 
Example from a car registration application:

public class PersonBean implements EntityBean
{
        ...
        Collection getRegisteredCars()
        {
                get home interface of Car
                return carHome.findByPerson( ctx.getEJBObject() );
        }
}

public class CarBean implements EntityBean
{
        ...
        Collection ejbFindByPerson( Person p )
        {
                use a method on p to get the foreign key for the car table
                do the sql lookup on the car table
        }

        Person getOwner()
        {
                ...
        }
}

In this case the call to getRegisteredCars will always result in deadlock.  The
client will wait for itself to finish with the Person object, which it never
will because it is waiting for the method which is waiting to finish, if you
see what I mean.

The other one, which you can't really do anything about, is when you have a
person, P, and a car, C, which is owned by P, and two clients, A and B.  If A
calls getRegisteredCars at about the same time as B calls getOwner, then you
will probably get deadlock between the two threads.  Nothing you can do except
wait for one of the transactions to time out and retry it.  Timeout is
settable, I think it's 300 seconds by default.

This tends to come up much more in benchmarking than in real world use, since a
benchmark typically consists of many threads all doing the same thing, so they
are likely to be accessing the same objects at about the same time.  In real
world use it is far less likely that two clients will call such methods on the
same bean with <1s of each other, so the problem is very rare.

Sorry if this is all really obvious to you and I've missed some deeper question
in your question.  I'm good at that sort of thing.

Tom


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to