]
Bela Ban edited comment on JGRP-2364 at 8/1/19 3:51 AM:
--------------------------------------------------------
The problem is that unlock() doesn't wait for the RELEASE_LOCK_OK response. If we do a
lock-unlock-lock sequence, the second lock() request will not send a GRANT_LOCK request if
the lock is still locked. This can happen if the second lock() is sent _before_ the
RELEASE_LOCK_OK response has been received.
Fix: block {{unlock()}} until the RELEASE_LOCK_OK response has been received (same as for
{{lock()}})
was (Author: belaban):
The problem is that unlock() doesn't wait for the RELEASE_LOCK_OK response. If we do a
lock-unlock-lock sequence, the second lock() request will not send a GRANT_LOCK request if
the lock is still locked. This can happen if the second lock() is sent _before_ the
RELEASE_LOCK_OK response has been received.
Fix: block`unlock()` until the RELEASE_LOCK_OK response has been received (same as for
`lock()`)
simply lock and unlock JGroups lock repeatedly will create chaos
----------------------------------------------------------------
Key: JGRP-2364
URL:
https://issues.jboss.org/browse/JGRP-2364
Project: JGroups
Issue Type: Bug
Affects Versions: 4.1.1
Environment: JDK: 1.8
JGroups: 4.1.1
Lock: CENTRAL_LOCK
Reporter: Yong Deng
Assignee: Bela Ban
Priority: Major
Fix For: 4.1.2
Attachments: LockSimpleTest.java
I have one simple use case to reproduce the issue. In same thread, just lock/unlock the
lock repeatedly. Turn the log level to TRACE, you will find the communication chaos
between the client and the coordinate. *JGroups unlock will return immediately after
sending out RELEASE_LOCK currently. Why unlock don’t wait and only return after receiving
the RELEASE_LOCK_OK response?*
* Current log:
{code:java}
16:56:40,399 TRACE [CENTRAL_LOCK] A --> A: GRANT_LOCK[sample-lock, lock_id=1,
owner=A::31, trylock, timeout=10000]
16:56:40,404 TRACE [CENTRAL_LOCK] A <-- A: GRANT_LOCK[sample-lock, lock_id=1,
owner=A::31, trylock, timeout=10000, sender=A]
16:56:40,410 TRACE [CENTRAL_LOCK] A --> A: LOCK_GRANTED[sample-lock, lock_id=1,
owner=A::31]
16:56:40,411 TRACE [CENTRAL_LOCK] A <-- A: LOCK_GRANTED[sample-lock, lock_id=1,
owner=A::31, sender=A]
16:56:40,413 TRACE [CENTRAL_LOCK] A --> A: RELEASE_LOCK[sample-lock, lock_id=1,
owner=A::31]
16:56:40,414 TRACE [CENTRAL_LOCK] A <-- A: RELEASE_LOCK[sample-lock, lock_id=1,
owner=A::31, sender=A]
16:56:40,414 TRACE [CENTRAL_LOCK] A --> A: RELEASE_LOCK[sample-lock, lock_id=1,
owner=A::31]
16:56:40,415 TRACE [CENTRAL_LOCK] A --> A: RELEASE_LOCK_OK[sample-lock, lock_id=1,
owner=A::31]
16:56:40,415 TRACE [CENTRAL_LOCK] A --> A: RELEASE_LOCK[sample-lock, lock_id=1,
owner=A::31]
{code}
* The expected log:
{code:java}
2019-07-24 17:01:52,849 TRACE [org.jgroups.protocols.CENTRAL_LOCK] [A] --> [A]
GRANT_LOCK [sample-lock, lock_id=1, owner=A::63, trylock (timeout=10000)
2019-07-24 17:01:52,849 TRACE [org.jgroups.protocols.CENTRAL_LOCK] [A] <-- [A]
GRANT_LOCK [sample-lock, lock_id=1, owner=A::63, trylock (timeout=10000)
2019-07-24 17:01:52,852 TRACE [org.jgroups.protocols.CENTRAL_LOCK] [A] --> [A]
LOCK_GRANTED [sample-lock, lock_id=1, owner=A::63 ]
2019-07-24 17:01:52,852 TRACE [org.jgroups.protocols.CENTRAL_LOCK] [A] <-- [A]
LOCK_GRANTED [sample-lock, lock_id=1, owner=A::63 ]
2019-07-24 17:01:52,853 TRACE [org.jgroups.protocols.CENTRAL_LOCK] [A] --> [A]
RELEASE_LOCK [sample-lock, lock_id=1, owner=A::63 ]
2019-07-24 17:01:52,853 TRACE [org.jgroups.protocols.CENTRAL_LOCK] [A] <-- [A]
RELEASE_LOCK [sample-lock, lock_id=1, owner=A::63 ]
2019-07-24 17:01:52,853 TRACE [org.jgroups.protocols.CENTRAL_LOCK] [A] --> [A]
RELEASE_LOCK_OK [sample-lock, lock_id=1, owner=A::63 ]
2019-07-24 17:01:52,854 TRACE [org.jgroups.protocols.CENTRAL_LOCK] [A] <-- [A]
RELEASE_LOCK_OK [sample-lock, lock_id=1, owner=A::63 ]
{code}