[
https://issues.apache.org/jira/browse/PHOENIX-6950?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Viraj Jasani resolved PHOENIX-6950.
-----------------------------------
Resolution: Fixed
> PhoenixDriver APIs should unlock closeLock only if thread is able to take lock
> ------------------------------------------------------------------------------
>
> Key: PHOENIX-6950
> URL: https://issues.apache.org/jira/browse/PHOENIX-6950
> Project: Phoenix
> Issue Type: Bug
> Reporter: Viraj Jasani
> Assignee: Viraj Jasani
> Priority: Major
> Fix For: 5.2.0, 5.1.4
>
>
> The bug surfaces rarely. We take read lock on closeLock as part of
> PhoenixDriver connect, getQueryServices, getConnectionQueryServices APIs.
> However, taking the locks is part of try block and we always try to perform
> the unlock on closeLock as part of finally block.
> If the lock could not be acquired because the current thread was interrupted,
> we should not be allowed to unlock it. We can resolve this by:
> # Allow taking read lock outside of try and deal with InterruptedException
> by throwing SQLException
> # Use additional arg in PhoenixDriver#lockInterruptibly to ensure whether
> the lock could not be obtained by the current thread and use the info while
> unlocking
>
> {code:java}
> Cause6: java.lang.IllegalMonitorStateException: attempt to unlock read lock,
> not locked by current thread
> Cause6-StackTrace: at
> java.base/java.util.concurrent.locks.ReentrantReadWriteLock$Sync.unmatchedUnlockException(ReentrantReadWriteLock.java:448)
> at
> java.base/java.util.concurrent.locks.ReentrantReadWriteLock$Sync.tryReleaseShared(ReentrantReadWriteLock.java:432)
> at
> java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.releaseShared(AbstractQueuedSynchronizer.java:1382)
> at
> java.base/java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.unlock(ReentrantReadWriteLock.java:897)
> at org.apache.phoenix.jdbc.PhoenixDriver.unlock(PhoenixDriver.java:371)
> at org.apache.phoenix.jdbc.PhoenixDriver.connect(PhoenixDriver.java:235)
> {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)