You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "James Taylor (JIRA)" <ji...@apache.org> on 2014/03/28 00:23:15 UTC

[jira] [Updated] (PHOENIX-901) Ensure ConnectionQueryServices only initialized once

     [ https://issues.apache.org/jira/browse/PHOENIX-901?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Taylor updated PHOENIX-901:
---------------------------------

    Attachment: phoenix.patch

This patch will cause clients to block on ConnectionQueryServices.init(). If the first one fails and throws, the blocked ones will fail too.

The calling Driver will remove the failed ConnectionQueryServices from its map, so clients may try to connect again.

> Ensure ConnectionQueryServices only initialized once
> ----------------------------------------------------
>
>                 Key: PHOENIX-901
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-901
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: James Taylor
>            Assignee: James Taylor
>         Attachments: phoenix.patch
>
>
> We should call connectionQueryServices#init in the else block of this code:
> {code}
>     @Override
>     protected ConnectionQueryServices getConnectionQueryServices(String url, Properties info) throws SQLException {
>         checkClosed();
>         ConnectionInfo connInfo = ConnectionInfo.create(url);
>         ConnectionInfo normalizedConnInfo = connInfo.normalize(getQueryServices().getProps());
>         ConnectionQueryServices connectionQueryServices = connectionQueryServicesMap.get(normalizedConnInfo);
>         if (connectionQueryServices == null) {
>             if (normalizedConnInfo.isConnectionless()) {
>                 connectionQueryServices = new ConnectionlessQueryServicesImpl(getQueryServices());
>             } else {
>                 connectionQueryServices = new ConnectionQueryServicesImpl(getQueryServices(), normalizedConnInfo);
>             }
>             connectionQueryServices.init(url, info);
>             ConnectionQueryServices prevValue = connectionQueryServicesMap.putIfAbsent(normalizedConnInfo, connectionQueryServices);
>             if (prevValue != null) {
>                 connectionQueryServices = prevValue;
>             }
>         }
>         return connectionQueryServices;
>     }
> {code}
> like this instead:
> {code}
>     @Override
>     protected ConnectionQueryServices getConnectionQueryServices(String url, Properties info) throws SQLException {
>         checkClosed();
>         ConnectionInfo connInfo = ConnectionInfo.create(url);
>         ConnectionInfo normalizedConnInfo = connInfo.normalize(getQueryServices().getProps());
>         ConnectionQueryServices connectionQueryServices = connectionQueryServicesMap.get(normalizedConnInfo);
>         if (connectionQueryServices == null) {
>             if (normalizedConnInfo.isConnectionless()) {
>                 connectionQueryServices = new ConnectionlessQueryServicesImpl(getQueryServices());
>             } else {
>                 connectionQueryServices = new ConnectionQueryServicesImpl(getQueryServices(), normalizedConnInfo);
>             }
>             ConnectionQueryServices prevValue = connectionQueryServicesMap.putIfAbsent(normalizedConnInfo, connectionQueryServices);
>             if (prevValue != null) {
>                 connectionQueryServices = prevValue;
>             } else {
>                 connectionQueryServices.init(url, info);
>             }
>         }
>         return connectionQueryServices;
>     }
> {code}
> This has the potential to open multiple HConnections, but it's unclear if this causes harm, as the same, original ConnectionQueryService is returned and used.



--
This message was sent by Atlassian JIRA
(v6.2#6252)