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

FineGrainedAtomicHashMap may not lock all the composite keys in optimistic locking

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: Major Major
    • 5.3.0.Final
    • 5.2.7.Final, 5.3.0.Final
    • Core

      In OptimisticLockingInterceptor, we are collecting the composite keys from ApplyDeltaCommand is the key belongs to the node:

      case ApplyDeltaCommand.COMMAND_ID:
        ApplyDeltaCommand command = (ApplyDeltaCommand) wc;
        if (cdl.localNodeIsOwner(command.getKey())) {
          Object[] compositeKeys = command.getCompositeKeys();
          set.addAll(Arrays.asList(compositeKeys));
        }
      break;
      

      However, when we are going to acquire the lock in the node if it is the primary owner:

      protected final void lockAndRegisterBackupLock(TxInvocationContext ctx, Object key, long lockTimeout, boolean skipLocking) throws InterruptedException {
        if (cdl.localNodeIsPrimaryOwner(key)) {
          lockKeyAndCheckOwnership(ctx, key, lockTimeout, skipLocking);
        } else if (cdl.localNodeIsOwner(key)) {
          ctx.getCacheTransaction().addBackupLockForKey(key);
        }
      }
      

      The CompositeKey should always acquire the lock.

      This is probably a bug. Add an unit test to verify that locking works as expected for AtomicHashMap.

              pruivo@redhat.com Pedro Ruivo
              pruivo@redhat.com Pedro Ruivo
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: