Failed to find reentrant lock with given name Ignite

Full text of the exception in Apache Ignite:

SEVERE: <ignite-sys-atomic-cache@default-volatile-ds-group> 
Failed to compare and set: o.a.i.i.processors.datastructures.GridCacheLockImpl$Sync$1@263fbc6 class org.apache.ignite.IgniteCheckedException: 
Failed to find reentrant lock with given name: <name_here>
 
SEVERE: <ignite-sys-atomic-cache@default-volatile-ds-group> 
Lock.unlock() is called in illegal state [callerNodeId=6686427d-f221-4364-61b0-e1df293e938d, ownerNodeId=null, callerThreadId=323, ownerThreadId=0, lockState=0]

The code that uses the reentrant lock looks something like this:

IgniteLock lock = ignite.reentrantLock(...);
lock.lock();
try {
    ...
} finally {
    lock.unlock();
}

Check that when creating a lock, the last argument = true is passed to the reentrantLock method:

ignite.reentrantLock(..., true);

If the error is still repeated, then this is a bug: https://issues.apache.org/jira/browse/IGNITE-3386. It appears when one of the server nods creates a lock and falls out of the topology. From the history of the Jira discussion, it is not entirely clear what happened to the bug in the end, but even in version 2.6.0 it can be obtained.

In my case, the appearance of this bug pointed me to the wrong topology. I assumed that I had 1 ignite server and 5 ignite clients running. It turned out that all clients were servers. But in the case of multiple server nodes, you need to found the workarounds.

Telegram channel

If you still have any questions, feel free to ask me in the comments under this article or write me at promark33@gmail.com.

If I saved your day, you can support me 🤝

One thought on “Failed to find reentrant lock with given name Ignite

  1. I have seem the same exception.But my situation is two servers and two clients as the following example
    [17:55:46] Topology snapshot [ver=33, servers=2, clients=2, CPUs=10, heap=9.0GB]

    When first client process lock a cache and i use debug mode let this process to stop at line 5
    At mean time i let client2 process also get same cache lock, then this process will stop at line3 waiting for client1 to unlock this lock.
    Then i kill the client1 process let this leave Ignite topology, then client2 process get following exception log, and this cache lock cannot rerentrant lock anymore.
    org.apache.ignite.IgniteCheckedException: Failed to find reentrant lock with given name: springSync326

    My question is when come across this situation how to auto unlock this broken lock, let client2 can lock this cache lock againg.

    [SpringCache.java -> get() ]
    1.if (val == null) {
    2. IgniteLock lock = mgr.getSyncLock(cache.getName(), key);
    3. lock.lock();
    4. try {
    5. val = cache.get(key);
    6. if (val == null) {
    7. try {
    8. T retVal = valLdr.call();
    9.
    10. val = wrapNull(retVal);

    cache.put(key, val);
    }
    catch (Exception e) {
    throw new ValueRetrievalException(key, valLdr, e);
    }
    }
    }
    finally {
    lock.unlock();
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *