7 Replies Latest reply on Nov 2, 2006 10:31 AM by Dmitry Kapustin

    Deadlock PojoCache.putObject()/org.apache.log4j.Category.cal

    Dmitry Kapustin Newbie

      Hi folks!

      We are using JBossCache within JBoss for quite some time and encountered that it can freeze JBoss.

      We have debugged one of such cases and discovered that there is deadlock which happens when the following conditions are met:

      1. Aspectization for our POJOs is used
      2. We add new element in a List field of a POJO
      3. Concurrently there is some thread running within our app which simply logs via Log4j user activities

      We found out that:

      1. When our POJO's List field gets modified replication of corresponding TreeCache node starts. We could see that there is some marshalling process is executed recursively according to "object cache by reachability".

      2. During the marshalling the cache even tries to marshall GmsImpl object with NON static field log which also gets marshalled. So, org.apache.log4j.Category.aai.appenderList.writeObject(...) gets invoked (actually, the category is the root category). Please note that this method is synchronized. Later within the same call chain some fatal error happen and the cache tries to log it and reaches Category.callAppenders() where synchronizes on root category.

      At this point the active thread acquired two locks: a) Vector's Category.aai.appenderList and b) Category's root instance

      3. Concurrently, our user activity logging thread tries to log as well. Here the locks are acquired in the opposite way which results in deadlock.

      Looks like something goes wrong here :)

      First, why GmsIml.log field is not static?
      Second, could it be a reasult of JBossCache misuse from our side?

      Thanks in advance for quite long reading :)

      Best regards,