[
https://issues.apache.org/jira/browse/PHOENIX-6950?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17720983#comment-17720983
]
Rushabh Shah commented on PHOENIX-6950:
---------------------------------------
> i think the only other thing we will have to take care of is to ensure
>SQLException remains same even with this approach.
I think we can swallow any exception coming out of PhoenixDriver.unlock method.
Just logging the exception within PhoenixDriver#unlock should be enough.
[~vjasani]
> 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
>
> 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)