You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by "Kezhu Wang (Jira)" <ji...@apache.org> on 2022/06/30 02:34:00 UTC

[jira] [Commented] (CURATOR-307) InterProcessReadWriteLock can throw IndexOutOfBoundsException when connection is lost

    [ https://issues.apache.org/jira/browse/CURATOR-307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17560790#comment-17560790 ] 

Kezhu Wang commented on CURATOR-307:
------------------------------------

This has been fixed by CURATOR-211. The line context matches {{77a1afbcc074d9ef87ba3bfc7d3cb641ad2f727e^}}.

> InterProcessReadWriteLock can throw IndexOutOfBoundsException when connection is lost
> -------------------------------------------------------------------------------------
>
>                 Key: CURATOR-307
>                 URL: https://issues.apache.org/jira/browse/CURATOR-307
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Recipes
>    Affects Versions: 2.4.0
>            Reporter: Jakub StrolenĂ½
>            Priority: Critical
>             Fix For: awaiting-response
>
>
> We are using recipe InterProcessMutex as lock for our cluster environment.
> We found that it is possible that acquiring and/or releasing of lock can fail when connection to ZooKeeper is lost or changed.
> If you have have following sample code:
> {code:java}
> InterProcessMutex.acquire();
> doSomething();
> InterProcessMutex.release();
> {code}
> You can get following exception in release() method, when connection is lost after lock is acquired.
> Stack trace:
> {code:java}
> java.lang.IllegalMonitorStateException: You do not own the lock: /clusters/Production/something/lock
> at org.apache.curator.framework.recipes.locks.InterProcessMutex.release(InterProcessMutex.java:128)
> {code}
> and following stack trace when lock directory is empty (because emphemeral nodes are deleted, because of connection was lost)
> {code:java}
> java.lang.IndexOutOfBoundsException: Index: 2147483647, Size: 0
> at java.util.ArrayList.rangeCheck(ArrayList.java:653)
> at java.util.ArrayList.get(ArrayList.java:429)
> at org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock.readLockPredicate(InterProcessReadWriteLock.java:190)
> at org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock.access$0(InterProcessReadWriteLock.java:163)
> at org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock$2.getsTheLock(InterProcessReadWriteLock.java:137)
> at org.apache.curator.framework.recipes.locks.LockInternals.internalLockLoop(LockInternals.java:287)
> at org.apache.curator.framework.recipes.locks.LockInternals.attemptLock(LockInternals.java:226)
> at org.apache.curator.framework.recipes.locks.InterProcessMutex.internalLock(InterProcessMutex.java:221)
> at org.apache.curator.framework.recipes.locks.InterProcessMutex.acquire(InterProcessMutex.java:77)
> {code}
> These operations should fail more gracefully, maybe with dedicated exception, when connection is lost or changed.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)