Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-3528

CacheLoaderTask implementation should be thread safe

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • 6.0.0.Beta2
    • 6.0.0.Alpha4
    • Transactions
    • None

    Description

      PersistenceManager.processOnAllStores receives a CacheLoaderTask parameter and calls it on potentially many threads concurrently. So the task object must be thread-safe.

      The CacheLoaderTask‍s used by CacheLoaderInterceptor.visitEntrySetCommand/visitKeySetCommand/visitValuesCommand are not thread-safe. They use a HashSet without any synchronization, and when accessed from concurrent threads the map can be corrupted. When this happens, the thread will block in an infinite loop:

      "testng-LocalModeNoPassivationTest" prio=10 tid=0x00007f19141ac800 nid=0x622c runnable [0x00007f1902a62000]
         java.lang.Thread.State: RUNNABLE
      	at java.util.HashMap.put(HashMap.java:498)
      	at java.util.HashSet.add(HashSet.java:217)
      	at java.util.AbstractCollection.addAll(AbstractCollection.java:342)
      	at org.infinispan.interceptors.CacheLoaderInterceptor.visitEntrySetCommand(CacheLoaderInterceptor.java:195)
              ...
      

      Attachments

        Activity

          People

            mircea.markus Mircea Markus (Inactive)
            dberinde@redhat.com Dan Berindei (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: