]
Bela Ban commented on JGRP-2220:
--------------------------------
I don't support such an old (4 years) version. Please try this with 3.6.x or 4.x!
I ran LockServiceDemo on master (4.0.7-SNAPSHOT):
* Start node A
* Start node B
* A: {{lock X}}: lock X is acquired successfully
* B: {{lock X}}: B blocks.
* A: {{unlock X}}: B acquires the lock
* CTRL-C A
* Restart node A
* A: {{lock X}}: this blocks until B calls unlock or is CTRL-C'ed
Note that trylock() with a long timeout is the same as lock(). Both lock methods passed in
this test
Two nodes can own a same lock at same time
------------------------------------------
Key: JGRP-2220
URL:
https://issues.jboss.org/browse/JGRP-2220
Project: JGroups
Issue Type: Bug
Affects Versions: 3.4
Environment: Two nodes cluster with jgroup 3.4.0 alpha2
Reporter: Xiao Li
Assignee: Bela Ban
Fix For: 4.0.7
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.