Skip to content

Commit

Permalink
[CONJ-583] Additional to ensure connection state when using intermedi…
Browse files Browse the repository at this point in the history
…ate proxy.

If a failover occurs during this internal queries, and there is some intermediate proxy that doesn't do is the job, even writing to socket doesn't permit to ensure socket state, leaving the driver hanging indefinitely.
Socket timeout is set for internal connection queries
  • Loading branch information
rusher committed Mar 3, 2018
1 parent ae52eee commit 86020a2
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -431,6 +431,7 @@ public void connect() throws SQLException {
private void connect(String host, int port) throws SQLException, IOException {
try {
socket = Utils.createSocket(urlParser, host);
if (options.socketTimeout != null) socket.setSoTimeout(options.socketTimeout);

initializeSocketOption();

Expand Down Expand Up @@ -492,8 +493,6 @@ private void connect(String host, int port) throws SQLException, IOException {
loadCalendar(globalInfo.getTimeZone(), globalInfo.getSystemTimeZone());
}

if (options.socketTimeout != null) socket.setSoTimeout(options.socketTimeout);

reader.setServerThreadId(this.serverThreadId, isMasterConnection());
writer.setServerThreadId(this.serverThreadId, isMasterConnection());

Expand Down Expand Up @@ -647,6 +646,10 @@ private void requestSessionDataWithShow(Map<String, String> serverData) throws S
}
serverData.put(resultSet.getString(1), resultSet.getString(2));
}
if (serverData.size() < 4) {
throw ExceptionMapper.connException("could not load system variables. socket connected: " + socket.isConnected());
}

} catch (SQLException sqlException) {
throw ExceptionMapper.connException("could not load system variables", sqlException);
}
Expand Down

0 comments on commit 86020a2

Please sign in to comment.