You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Nicky Sandhu <ka...@gmail.com> on 2007/10/17 23:40:59 UTC
Deadlocks again :(
Hi folks,
I got hit by another deadlock condition. Thats two different ones on two
consecutive days :(
In ActiveMQ I see a lot of blocks of code using synchronized access, nothing
wrong with that but this increases the potential for deadlocks as evidenced
by the last two problems I have hit within the span of a couple of days
(https://issues.apache.org/activemq/browse/AMQ-1467,
https://issues.apache.org/activemq/browse/AMQ-1468)
This may be just my luck but I think it points to concurrency 101 lessons
(http://undergraduate.csse.uwa.edu.au/units/CITS3213/lectures2/lect4.pdf)
some which are a.) Lock on the appropriate object 2.) don't hold locks for
longer than absolutely necessary 3.) avoid nested locks like the plague. 4.)
Establish locking order for nested locks etc.
Thoughts?
Nicky
BTW. JConsole has a cool detect deadlock feature in jdk6 which makes this
exercise quick (once you stumble across the deadlock that is >:)) + this
article (http://www.javaspecialists.eu/archive/Issue130.html) has code that
you can run periodically to dump them when they happen... something to be
included in perhaps a debug version to help root all these out ?
--
View this message in context: http://www.nabble.com/Deadlocks-again-%3A%28-tf4643498s2354.html#a13263508
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: Deadlocks again :(
Posted by Rob Davies <ra...@gmail.com>.
Thanks Nicky - really appreciate the input and help!! Will look at
adding the dead lock detection code
cheers,
Rob
http://rajdavies.blogspot.com/
On Oct 18, 2007, at 3:07 PM, Nicky Sandhu wrote:
>
> Hi Rob,
> It was not my intention to question your skill, rather it was to
> point that
> synchronizations lead to deadlocks (potentially) and they are too
> difficult
> to predict and code review. So I was proposing adding a deadlock
> detector
> like the one referenced below to optional activemq code.
> I see a lot of threads on hung producer/consumer/broker issues and
> if such
> a deadlock detector could be run either on demand or periodically
> it would
> help the team in pinpointing deadlock issues. Ofcourse not all hung
> issues
> would be deadlocks but this can't hurt.
>
> Very gently,
> Nicky
>
> rajdavies wrote:
>>
>> Thanks Nicky!
>>
>> will apply patches asap - we're usually pretty good at avoiding
>> deadlocks :(
>>
>>
>> cheers,
>>
>> Rob
>>
>> http://rajdavies.blogspot.com/
>>
>>
>>
>> On Oct 17, 2007, at 10:40 PM, Nicky Sandhu wrote:
>>
>>>
>>> Hi folks,
>>> I got hit by another deadlock condition. Thats two different ones
>>> on two
>>> consecutive days :(
>>>
>>> In ActiveMQ I see a lot of blocks of code using synchronized
>>> access, nothing
>>> wrong with that but this increases the potential for deadlocks as
>>> evidenced
>>> by the last two problems I have hit within the span of a couple of
>>> days
>>> (https://issues.apache.org/activemq/browse/AMQ-1467,
>>> https://issues.apache.org/activemq/browse/AMQ-1468)
>>>
>>> This may be just my luck but I think it points to concurrency 101
>>> lessons
>>> (http://undergraduate.csse.uwa.edu.au/units/CITS3213/lectures2/
>>> lect4.pdf)
>>> some which are a.) Lock on the appropriate object 2.) don't hold
>>> locks for
>>> longer than absolutely necessary 3.) avoid nested locks like the
>>> plague. 4.)
>>> Establish locking order for nested locks etc.
>>>
>>> Thoughts?
>>>
>>> Nicky
>>>
>>> BTW. JConsole has a cool detect deadlock feature in jdk6 which
>>> makes this
>>> exercise quick (once you stumble across the deadlock that is >:)) +
>>> this
>>> article (http://www.javaspecialists.eu/archive/Issue130.html) has
>>> code that
>>> you can run periodically to dump them when they happen... something
>>> to be
>>> included in perhaps a debug version to help root all these out ?
>>> --
>>> View this message in context: http://www.nabble.com/Deadlocks-again-
>>> %3A%28-tf4643498s2354.html#a13263508
>>> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Deadlocks-again-
> %3A%28-tf4643498s2354.html#a13275334
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>
Re: Deadlocks again :(
Posted by Nicky Sandhu <ka...@gmail.com>.
Hi Rob,
It was not my intention to question your skill, rather it was to point that
synchronizations lead to deadlocks (potentially) and they are too difficult
to predict and code review. So I was proposing adding a deadlock detector
like the one referenced below to optional activemq code.
I see a lot of threads on hung producer/consumer/broker issues and if such
a deadlock detector could be run either on demand or periodically it would
help the team in pinpointing deadlock issues. Ofcourse not all hung issues
would be deadlocks but this can't hurt.
Very gently,
Nicky
rajdavies wrote:
>
> Thanks Nicky!
>
> will apply patches asap - we're usually pretty good at avoiding
> deadlocks :(
>
>
> cheers,
>
> Rob
>
> http://rajdavies.blogspot.com/
>
>
>
> On Oct 17, 2007, at 10:40 PM, Nicky Sandhu wrote:
>
>>
>> Hi folks,
>> I got hit by another deadlock condition. Thats two different ones
>> on two
>> consecutive days :(
>>
>> In ActiveMQ I see a lot of blocks of code using synchronized
>> access, nothing
>> wrong with that but this increases the potential for deadlocks as
>> evidenced
>> by the last two problems I have hit within the span of a couple of
>> days
>> (https://issues.apache.org/activemq/browse/AMQ-1467,
>> https://issues.apache.org/activemq/browse/AMQ-1468)
>>
>> This may be just my luck but I think it points to concurrency 101
>> lessons
>> (http://undergraduate.csse.uwa.edu.au/units/CITS3213/lectures2/
>> lect4.pdf)
>> some which are a.) Lock on the appropriate object 2.) don't hold
>> locks for
>> longer than absolutely necessary 3.) avoid nested locks like the
>> plague. 4.)
>> Establish locking order for nested locks etc.
>>
>> Thoughts?
>>
>> Nicky
>>
>> BTW. JConsole has a cool detect deadlock feature in jdk6 which
>> makes this
>> exercise quick (once you stumble across the deadlock that is >:)) +
>> this
>> article (http://www.javaspecialists.eu/archive/Issue130.html) has
>> code that
>> you can run periodically to dump them when they happen... something
>> to be
>> included in perhaps a debug version to help root all these out ?
>> --
>> View this message in context: http://www.nabble.com/Deadlocks-again-
>> %3A%28-tf4643498s2354.html#a13263508
>> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>>
>
>
>
--
View this message in context: http://www.nabble.com/Deadlocks-again-%3A%28-tf4643498s2354.html#a13275334
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: Deadlocks again :(
Posted by Rob Davies <ra...@gmail.com>.
Thanks Nicky!
will apply patches asap - we're usually pretty good at avoiding
deadlocks :(
cheers,
Rob
http://rajdavies.blogspot.com/
On Oct 17, 2007, at 10:40 PM, Nicky Sandhu wrote:
>
> Hi folks,
> I got hit by another deadlock condition. Thats two different ones
> on two
> consecutive days :(
>
> In ActiveMQ I see a lot of blocks of code using synchronized
> access, nothing
> wrong with that but this increases the potential for deadlocks as
> evidenced
> by the last two problems I have hit within the span of a couple of
> days
> (https://issues.apache.org/activemq/browse/AMQ-1467,
> https://issues.apache.org/activemq/browse/AMQ-1468)
>
> This may be just my luck but I think it points to concurrency 101
> lessons
> (http://undergraduate.csse.uwa.edu.au/units/CITS3213/lectures2/
> lect4.pdf)
> some which are a.) Lock on the appropriate object 2.) don't hold
> locks for
> longer than absolutely necessary 3.) avoid nested locks like the
> plague. 4.)
> Establish locking order for nested locks etc.
>
> Thoughts?
>
> Nicky
>
> BTW. JConsole has a cool detect deadlock feature in jdk6 which
> makes this
> exercise quick (once you stumble across the deadlock that is >:)) +
> this
> article (http://www.javaspecialists.eu/archive/Issue130.html) has
> code that
> you can run periodically to dump them when they happen... something
> to be
> included in perhaps a debug version to help root all these out ?
> --
> View this message in context: http://www.nabble.com/Deadlocks-again-
> %3A%28-tf4643498s2354.html#a13263508
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>