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

Solr possible deadlock source (FindBugs report)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 1.4.1, 1.5, 3.1, 4.0-ALPHA
    • Component/s: None
    • Labels:
      None
    • Environment:

      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

            • Assignee:
              hossman Hoss Man
              Reporter:
              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