Thanks for spotting this. AbstractStripedLockContainer.releaseLock()
should not throw this exception because of the very reason documented in possiblyLocked()
- the contents of AbstractStripedLockContainer.releaseLock() should be wrapped in a try
block and should catch and (maybe) log IMSE's.
Could you pls create a JIRA for this? Should be a very simple fix.
On 3 Feb 2011, at 19:52, Sanne Grinovero wrote:
> Hello all,
> I am getting an "IllegalMonitorStateException" while Infinispan
> attempts to release a lock it doesn't own, basically at:
>
org.infinispan.container.EntryFactoryImpl.wrapEntryForWriting(EntryFactoryImpl.java:178
>
> (I was using SKIP_LOCKING, so lockAcquired is false at this point).
> I tried to fix it introducing an "if (lockAcquired)" in line 178, but
> then the situation seems worse:
>
> In "LockManagerImpl", line 174, reads:
>
> boolean needToUnlock = possiblyLocked(entry)
>
> where the javadoc of possiblyLocked reads:
>
> "Inspects the entry for signs that it is possibly locked, and hence
> would need to be unlocked. Note that this is not deterministic, and is
> pessimistic in that even if an entry is not locked but *might* be
> locked, this will return true.
> As such, this should only be used to determine whether *unlocking* is
> necessary, not whether locking is necessary. Unlocking an entry that
> has not been locked has no effect, so this is just an optimisation. "
>
> Still, some assumption seems wrong here as I'm experiencing the
> following stacktrace :
>
> java.lang.IllegalMonitorStateException
> at
java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:127)
> at
java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1239)
> at java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:431)
> at
org.infinispan.util.concurrent.locks.containers.AbstractStripedLockContainer.releaseLock(AbstractStripedLockContainer.java:97)
> at
org.infinispan.util.concurrent.locks.LockManagerImpl.unlock(LockManagerImpl.java:111)
> at
org.infinispan.util.concurrent.locks.LockManagerImpl.releaseLocks(LockManagerImpl.java:183)
> at
org.infinispan.interceptors.LockingInterceptor.cleanupLocks(LockingInterceptor.java:407)
> at
org.infinispan.interceptors.LockingInterceptor.cleanLocksAndRethrow(LockingInterceptor.java:412)
> at
org.infinispan.interceptors.LockingInterceptor.visitReplaceCommand(LockingInterceptor.java:340)
> at
org.infinispan.commands.write.ReplaceCommand.acceptVisitor(ReplaceCommand.java:59)
> at
org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
> at
org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:132)
> at
org.infinispan.commands.AbstractVisitor.visitReplaceCommand(AbstractVisitor.java:66)
> at
org.infinispan.commands.write.ReplaceCommand.acceptVisitor(ReplaceCommand.java:59)
> at
org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
> at
org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:184)
> at
org.infinispan.interceptors.TxInterceptor.visitReplaceCommand(TxInterceptor.java:142)
> at
org.infinispan.interceptors.DistTxInterceptor.visitReplaceCommand(DistTxInterceptor.java:90)
> at
org.infinispan.commands.write.ReplaceCommand.acceptVisitor(ReplaceCommand.java:59)
> at
org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
> at
org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:87)
> at
org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:58)
> at
org.infinispan.commands.AbstractVisitor.visitReplaceCommand(AbstractVisitor.java:66)
> at
org.infinispan.commands.write.ReplaceCommand.acceptVisitor(ReplaceCommand.java:59)
> at
org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:273)
> at org.infinispan.CacheDelegate.replace(CacheDelegate.java:475)
> at org.infinispan.CacheSupport.replace(CacheSupport.java:96)
> at
org.infinispan.lucene.readlocks.DistributedSegmentReadLocker.acquireReadLock(DistributedSegmentReadLocker.java:146)
> at
org.infinispan.lucene.readlocks.StressTestReadLocksTest$LockUser.run(StressTestReadLocksTest.java:74)
> at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:662)
>
> It's totally possible that the exception wouldn't happen without my
> "fix" mentioned above, but then I get the IllegalMonitorStateException
> earlier.
> Any hint?
>
> I'm sharing my failing testcase on GitHub, branch
> "IllegalMonitorStateException", forked from 4.2.x :
>
https://github.com/Sanne/infinispan/tree/IllegalMonitorStateException
>
> Cheers,
> Sanne
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/infinispan-dev
--
Manik Surtani
manik(a)jboss.org
twitter.com/maniksurtani
Lead, Infinispan
http://www.infinispan.org
_______________________________________________
infinispan-dev mailing list
infinispan-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev