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

Infinite loop in TransactionAwareCloseableIterator when iterating through cache...

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

XMLWordPrintable

      Hi,

      i have some testing code that iterates through a cache and validates all data in this cache for consistency.

      The reduced code is:

      TransactionManager tm = cache.getAdvancedCache().getTransactionManager();
      tm.begin();
      try {
      for (Entry<Object,Object> entry : metadataCache.entrySet())

      { // validation code omitted... }

      } finally {
      tm.commit();
      }

      In some circumstances the iteration starts returning the same Entry every time. I stepped into the code and the value is returned from:
      https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/iteration/impl/TransactionAwareCloseableIterator.java#L70
      This code block is commented with:
      "// We do a last check to make sure no additional values were added to our context while iterating"

      And for me it seems that the value returned here never gets added to the "seenContextKeys" Set and so the iterator is always returning the same key.
      Maybe a simple "seenContextKeys.add(lookedUpEntry.getKey())" next to Line 70 would fix this issue. Maybe even a 'break' could make sense here because is there the need to walk through the entire list if we have found a candidate?

              wburns@redhat.com Will Burns
              cniessner Christian Niessner (Inactive)
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: