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

CacheLoaderTask implementation should be thread safe

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 6.0.0.Final
    • 6.0.0.Final
    • Transactions
    • None

      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)
              ...
      

              mircea.markus Mircea Markus (Inactive)
              dberinde@redhat.com Dan Berindei (Inactive)
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: