Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-1538

Solr possible deadlock source (FindBugs report)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.4
    • 1.4.1, 1.5, 3.1, 4.0-ALPHA
    • None
    • None
    • platform independent

    Description

      The code to get the latest accessed items in ConcurrentLRUCache looks like

      ConcurrentLRUCache.java
       public Map<K, V> getOldestAccessedItems(int n) {
          markAndSweepLock.lock();
          Map<K, V> result = new LinkedHashMap<K, V>();
          TreeSet<CacheEntry> tree = new TreeSet<CacheEntry>();
          try {
         ...
          } finally {
            markAndSweepLock.unlock();
          }
      

      (this method is apparently unused though) and in

         public Map<K,V> getLatestAccessedItems(int n) {
           // we need to grab the lock since we are changing lastAccessedCopy
           markAndSweepLock.lock();
           Map<K,V> result = new LinkedHashMap<K,V>();
           TreeSet<CacheEntry> tree = new TreeSet<CacheEntry>();
           try {
      ...
      

      The impression is that if an OOM situation occurs on the allocation of the local LinkedHashMap and TreeSet the lock would not be unlocked anymore.
      The quick fix would be to move the lock() call after the allocations, and this does not seem to imply any problem.

      Attachments

        1. SOLR-1538.patch
          1 kB
          gabriele renzi

        Activity

          People

            hossman Chris M. Hostetter
            riffraff gabriele renzi
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 10m
                10m
                Remaining:
                Remaining Estimate - 10m
                10m
                Logged:
                Time Spent - Not Specified
                Not Specified