Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1938

Potentially uninitialized workspace caches can be leaked from repository cache

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Blocker
    • 3.3.0.Final
    • 3.2.0.Final
    • None
    • None
    • Hide

      I was able to reproduce this using the org.modeshape.jcr.AuthenticationAndAuthorizationTest class and adding the following snippet of code:

       public static void main( String[] args ) throws Exception {
              AuthenticationAndAuthorizationTest test = new AuthenticationAndAuthorizationTest();
              beforeAll();
              int runCount = 1000;
              for (int i = 0; i < runCount; i++) {
                  System.out.println("Pass " + i);
                  test.beforeEach();
                  test.shouldLogInAsAnonymousUserIfNoProviderAuthenticatesCredentials();
                  test.afterEach();
              }
              afterAll();
          }
      
      Show
      I was able to reproduce this using the org.modeshape.jcr.AuthenticationAndAuthorizationTest class and adding the following snippet of code: public static void main( String [] args ) throws Exception { AuthenticationAndAuthorizationTest test = new AuthenticationAndAuthorizationTest(); beforeAll(); int runCount = 1000; for ( int i = 0; i < runCount; i++) { System .out.println( "Pass " + i); test.beforeEach(); test.shouldLogInAsAnonymousUserIfNoProviderAuthenticatesCredentials(); test.afterEach(); } afterAll(); }

    Description

      WorkspaceCache instances are initialized lazily, when a client code first calls the RepositoryCache#workspace method. The whole initialization procedure is done inside a user transaction, so that entries in ISPN are correctly persited.

      The current code has a bug in that if multiple threads call this method, the cache of workspace caches from RepositoryCache exposes a new WorkspaceCache instance before transaction.commit has occurred.

      In other words, a thread may get a WorkspaceCache reference even though the data corresponding to that workspace cache has not been persisted in ISPN.

      This can be seen sometimes while running the tests, when error messages such as:

      Exception in thread "main" javax.jcr.ItemNotFoundException: The node with key ee0a8387505d64/ no longer exists.
      	at org.modeshape.jcr.AbstractJcrNode.node(AbstractJcrNode.java:216)
      	at org.modeshape.jcr.AbstractJcrNode.path(AbstractJcrNode.java:236)
      	at org.modeshape.jcr.AbstractJcrNode.addNode(AbstractJcrNode.java:1002)
      	at org.modeshape.jcr.AbstractJcrNode.addNode(AbstractJcrNode.java:925)
      

      pop up. They are caused by the asynchronous indexing threads "colliding" with the main test threads.

      Attachments

        Activity

          People

            hchiorean Horia Chiorean (Inactive)
            hchiorean Horia Chiorean (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: