Jackrabbit Content Repository
  1. Jackrabbit Content Repository
  2. JCR-2106

SystemSessions created for GarbageCollector are not logged out of

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.5
    • Fix Version/s: 1.5.7
    • Component/s: jackrabbit-core
    • Labels:
      None

      Description

      I have a simple garbage collection task that runs periodically. After upgrading to 1.5.5 it started logging a warning shortly after each run:

      2009-05-09 03:44:45,480 WARN [org.apache.jackrabbit.core.SessionImpl] - <Unclosed session detected. The session was opened here: >
      java.lang.Exception: Stack Trace
      at org.apache.jackrabbit.core.SessionImpl.<init>(SessionImpl.java:239)
      at org.apache.jackrabbit.core.SystemSession.<init>(SystemSession.java:76)
      at org.apache.jackrabbit.core.SystemSession.create(SystemSession.java:64)
      at org.apache.jackrabbit.core.SessionImpl.createDataStoreGarbageCollector(SessionImpl.java:649)

      So it's not my session, but an internally created SystemSession.

      Code I'm using:
      getTemplate().execute(new JcrCallback()
      {
      public Object doInJcr(Session session)
      throws IOException, RepositoryException

      { SessionImpl sessionImpl = (SessionImpl)session; GarbageCollector gc = sessionImpl.createDataStoreGarbageCollector(); gc.scan(); gc.stopScan(); gc.deleteUnused(); return null; }

      }, true);

      1. JCR-2106.patch
        2 kB
        Peter Dettman
      2. JCR-2106-2nd.patch
        2 kB
        Peter Dettman
      3. JCR-2106-3rd.patch
        2 kB
        Peter Dettman

        Issue Links

          Activity

          Peter Dettman created issue -
          Peter Dettman made changes -
          Field Original Value New Value
          Link This issue is related to JCR-1216 [ JCR-1216 ]
          Hide
          Peter Dettman added a comment -

          The attached patch for GarbageCollector logs out of the internal SystemSession objects when the user session has logged out, which resolves this for me locally.

          Show
          Peter Dettman added a comment - The attached patch for GarbageCollector logs out of the internal SystemSession objects when the user session has logged out, which resolves this for me locally.
          Peter Dettman made changes -
          Attachment JCR-2106.patch [ 12407646 ]
          Thomas Mueller made changes -
          Assignee Thomas Mueller [ tmueller ]
          Thomas Memenga committed 773555 (1 file)
          Reviews: none

          JCR-2106 SystemSessions created for GarbageCollector are not logged out

          Thomas Mueller made changes -
          Issue Type Bug [ 1 ] Improvement [ 4 ]
          Hide
          Thomas Mueller added a comment -

          Committed in revision 773555 (trunk)
          Thanks a lot for the patch!

          Show
          Thomas Mueller added a comment - Committed in revision 773555 (trunk) Thanks a lot for the patch!
          Thomas Mueller made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          Peter Dettman added a comment -

          You're welcome... unfortunately the previous patch was not quite right. The GarbageCollector needs to keep a reference to the session listener or it may be garbage collected (the session only holds weak references to its listeners). I observed this actually occurring in testing on the latest build.

          Show
          Peter Dettman added a comment - You're welcome... unfortunately the previous patch was not quite right. The GarbageCollector needs to keep a reference to the session listener or it may be garbage collected (the session only holds weak references to its listeners). I observed this actually occurring in testing on the latest build.
          Peter Dettman made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Hide
          Peter Dettman added a comment -

          Patch against latest build (on top of previous patch). Stores the session listener in a field of GarbageCollector so that it is not collected.

          Also moves the closing of the system sessions from loggedOut() to loggingOut(); it seems more appropriate that the lifetime of those system sessions be bounded by the parent session.

          Show
          Peter Dettman added a comment - Patch against latest build (on top of previous patch). Stores the session listener in a field of GarbageCollector so that it is not collected. Also moves the closing of the system sessions from loggedOut() to loggingOut(); it seems more appropriate that the lifetime of those system sessions be bounded by the parent session.
          Peter Dettman made changes -
          Attachment JCR-2106-2nd.patch [ 12407799 ]
          Hide
          Thomas Mueller added a comment -

          Hm, the GarbageCollector object could be garbage collected before the session is closed.
          That means keeping a hard reference from the GarbageCollector to the listener
          wouldn't help, right?

          It looks like we need a new method GarbageCollector.close(), and a finalize() method
          (in case people forgot to call close()).

          Show
          Thomas Mueller added a comment - Hm, the GarbageCollector object could be garbage collected before the session is closed. That means keeping a hard reference from the GarbageCollector to the listener wouldn't help, right? It looks like we need a new method GarbageCollector.close(), and a finalize() method (in case people forgot to call close()).
          Hide
          Peter Dettman added a comment -

          Ignore the 2nd patch, I've attached a 3rd that incorporates close/finalize as suggested.

          Show
          Peter Dettman added a comment - Ignore the 2nd patch, I've attached a 3rd that incorporates close/finalize as suggested.
          Peter Dettman made changes -
          Attachment JCR-2106-3rd.patch [ 12408778 ]
          Thomas Memenga committed 779084 (1 file)
          Reviews: none

          JCR-2106 SystemSessions created for GarbageCollector are not logged out

          Hide
          Thomas Mueller added a comment -

          Thanks a lot for the patch!

          Committed in revision 779084 (trunk)

          Show
          Thomas Mueller added a comment - Thanks a lot for the patch! Committed in revision 779084 (trunk)
          Thomas Mueller made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Jukka Zitting made changes -
          Fix Version/s 1.6.0 [ 12313459 ]
          Jukka N committed 791440 (1 file)
          Reviews: none

          1.x: Use SynchronizedBoolean from concurrent.jar instead of the Java 5 AtomicBoolean (JCR-2106)

          Jukka Zitting made changes -
          Workflow jira [ 12462948 ] no-reopen-closed, patch-avail [ 12468020 ]
          Jukka N committed 791879 (1 file)
          Reviews: none

          1.x: Merged revision 773555 (JCR-2106).

          Jukka N committed 794213 (3 files)
          Hide
          Jukka Zitting added a comment -

          Merged to the 1.5 branch in revision 794213.

          Show
          Jukka Zitting added a comment - Merged to the 1.5 branch in revision 794213.
          Jukka Zitting made changes -
          Fix Version/s 1.5.7 [ 12314103 ]
          Fix Version/s 1.6.0 [ 12313459 ]
          Jukka Zitting made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Thomas Mueller
              Reporter:
              Peter Dettman
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development