Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1158

Deadlock between SFSB Synchronization lock and Weld AbstractContext session context lock

XMLWordPrintable

    • Hide

      1. deploy the attached jboss-as-helloworld.war
      2. go to http://127.0.0.1:8080/jboss-as-helloworld/Welcome
      3. open the "Demand" link in the background
      4. open the "Thing" link immediately after (<2000ms) 3.

      5. Notice the "javax.ejb.ConcurrentAccessTimeoutException: JBAS014360: EJB 3.1 FR 4.3.14.1 concurrent access timeout on org.jboss.invocation.InterceptorContext@3fc7cf1 - could not obtain lock within 5000 MILLISECONDS" error page on the Thing page

      Show
      1. deploy the attached jboss-as-helloworld.war 2. go to http://127.0.0.1:8080/jboss-as-helloworld/Welcome 3. open the "Demand" link in the background 4. open the "Thing" link immediately after (<2000ms) 3. 5. Notice the "javax.ejb.ConcurrentAccessTimeoutException: JBAS014360: EJB 3.1 FR 4.3.14.1 concurrent access timeout on org.jboss.invocation.InterceptorContext@3fc7cf1 - could not obtain lock within 5000 MILLISECONDS" error page on the Thing page

      There is a deadlock between SFSB Synchronization lock and the Weld AbstractContext session context lock, which causes the SFSB and the session context to be locked until the SFSB lock timeouts with javax.ejb.ConcurrentAccessTimeoutException.

      The situation can be caused by a producer inside a SFSB, such as:

      @Stateful
      @SessionScoped
      public class StatefulProducer
      {
         @Inject
         private Instance<OnDemandBean> onDemandBean;
         
         @Produces
         @SessionScoped
         public Thing getThing() {
            return new Thing();
         }
         
         public void demand() {
            Thread.sleep(2000);      
            onDemandBean.get().foo();
         }
      }
      
      @SessionScoped
      public class OnDemandBean implements Serializable {
         public void foo() {}
      }
      

      The problem occurs when there are two requests in the same session, with the first one calling StatefulProducer.demand and the other request injecting the Thing. The first request locks the SFSB synchronization lock first and then the Weld AbstractContext lock during the "onDemandBean.get()" call. The second request locks the Weld AbstractContext lock first and the SFSB synchronization lock next (during the producer getThing() call)

        1. helloworld.tar.gz
          5 kB
          Marek Schmidt
        2. jboss-as-helloworld.war
          9 kB
          Marek Schmidt
        3. jstack.txt
          41 kB
          Marek Schmidt

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              maschmid@redhat.com Marek Schmidt
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: