[
https://issues.apache.org/jira/browse/PHOENIX-1143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14091015#comment-14091015
]
James Taylor commented on PHOENIX-1143:
---------------------------------------
Thanks for the patch, [~samarthjain]. Nice work! One minor comment:
- Don't change the PhoenixDriver.acceptsURL() method, as that's not dependent
on the state of the driver. It just determines that a Driver may or may not be
applicable for a given URL. If/when the acceptsUrl returns true, the next thing
DriverManager would typically try to do is establish a new connection which
would go through the guards you've put into place.
{code}
@Override
public boolean acceptsURL(String url) throws SQLException {
- // Accept the url only if test=true attribute not set
- return super.acceptsURL(url) && !isTestUrl(url);
+ try {
+ closeLock.readLock().lock();
+ checkClosed();
+ // Accept the url only if test=true attribute not set
+ return super.acceptsURL(url) && !isTestUrl(url);
+ } finally {
+ closeLock.readLock().unlock();
+ }
+
}
{code}
Would you mind undoing this change and then getting patches ready for all
branches? Might want to wait until [~jeffreyz] commits his patch and then
rebase, as there may be conflicts (not sure, though).
> Prevent race condition between creating phoenix connection and closing
> phoenix driver/connection query services.
> ----------------------------------------------------------------------------------------------------------------
>
> Key: PHOENIX-1143
> URL: https://issues.apache.org/jira/browse/PHOENIX-1143
> Project: Phoenix
> Issue Type: Bug
> Reporter: Samarth Jain
> Assignee: Samarth Jain
> Fix For: 5.0.0, 3.1, 4.1
>
> Attachments: PHOENIX-1143-3.0.patch, PHOENIX-1143_v3.patch
>
>
> The race condition manifests when the following NPE is thrown:
> {code}
> java.lang.NullPointerException
> Thrown-StackTrace: at
> org.apache.phoenix.jdbc.PhoenixConnection.<init>(PhoenixConnection.java:178)
> at
> org.apache.phoenix.query.ConnectionQueryServicesImpl.connect(ConnectionQueryServicesImpl.java:513)
> at
> org.apache.phoenix.jdbc.PhoenixEmbeddedDriver.connect(PhoenixEmbeddedDriver.java:116)
> {code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)