Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2220

Two nodes can own a same lock at same time

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • 4.0.7
    • 3.4
    • None
    • Hide

      1. node1 makes call
      lock = lockManager.getLock(lockId);
      lock.tryLock(Long.MAX_VALUE, TimeUnit.MILLISECONDS); so it gets the lock

      2. node2 makes same call so it waits for lock.

      3. The node1 makes call lock.unlock() so it releases the lock and node2 gets the lock.

      4. Shutdown JVM of the node1

      5. Restart JVM of the node1

      6. node1 gets that lock.

      Show
      1. node1 makes call lock = lockManager.getLock(lockId); lock.tryLock(Long.MAX_VALUE, TimeUnit.MILLISECONDS); so it gets the lock 2. node2 makes same call so it waits for lock. 3. The node1 makes call lock.unlock() so it releases the lock and node2 gets the lock. 4. Shutdown JVM of the node1 5. Restart JVM of the node1 6. node1 gets that lock.

      We have a two node cluster with following protocol stack for distributed lock.
      lock.protocolStack=UDP(bind_addr=myIP;bind_port=31562;mcast_addr=239.255.166.17;mcast_port=31569;ip_ttl=32;mcast_send_buf_size=150000;mcast_recv_buf_size=80000):PING(timeout=2000;num_initial_members=3):MERGE2(min_interval=5000;max_interval=10000):FD_ALL(interval=5000;timeout=20000):VERIFY_SUSPECT(timeout=1500):pbcast.NAKACK(retransmit_timeout=300,600,1200,2400,4800):UNICAST(timeout=5000):pbcast.STABLE(desired_avg_gossip=20000):FRAG(frag_size=8096):pbcast.GMS(join_timeout=5000;print_local_addr=true):CENTRAL_LOCK(num_backups=2)

      We use the following call to get a lock for one node.
      lock = lockManager.getLock(lockId);
      lock.tryLock(Long.MAX_VALUE, TimeUnit.MILLISECONDS); where lockManager is an object of LockService and lock is a Lock object.
      Another node is waiting on the lock at same method call. When the node owning the lock release the lock with the call lock.unlock(), the node waiting on the lock gets the lock and the lock is deleted from the node owned the lock. When the JVM for the node that released the lock restarted, it can also get same lock. So two nodes own the lock at same time.

      If I don't call lock.unlock() before shutting down the node, it waits for the lock as expected when its JVM starts up.

              rhn-engineering-bban Bela Ban
              cs2000xli Xiao Li (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: