Elffuss BraidHub

kikocis/java-driver public

Defunct connection on request timeout (JAVA-425).
Changeset46e39b8b4a39485e094c7ab97bb07bbe6b9716da7d4a49285f0c458d5104f420
Authorolim7t <omichallat+github@gmail.com> · 2014-09-17 17:07 -07:00
Committerolim7t <omichallat+github@gmail.com> · 2014-09-23 11:34 +02:00
Parents8b1fec78dfd4

Browse the files at this changeset

3 files changed

modified driver-core/CHANGELOG.rst +1 −0
@@ -6,6 +6,7 @@
66
77 - [bug] Handle null pool in PooledConnection.release (JAVA-449)
88 - [bug] Prevent concurrent retries of the same query (JAVA-449)
9+- [improvement] Defunct connection on request timeout (JAVA-425)
910
1011
1112 2.0.6:
modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +0 −1
@@ -827,7 +827,6 @@
827827 @Override
828828 public void run(Timeout timeout) {
829829 callback.onTimeout(connection, System.nanoTime() - startTime);
830- cancelHandler();
831830 }
832831 };
833832 }
modified driver-core/src/main/java/com/datastax/driver/core/RequestHandler.java +5 −3
@@ -513,10 +513,12 @@
513513 public void onTimeout(Connection connection, long latency) {
514514 Host queriedHost = current;
515515 try {
516- if (connection instanceof PooledConnection)
517- ((PooledConnection)connection).release();
516+ // If a query times out, we consider that the host is unstable, so we defunct
517+ // the connection to mark it down.
518+ DriverException timeoutException = new DriverException("Timed out waiting for server response");
519+ connection.defunct(timeoutException);
518520
519- logError(connection.address, new DriverException("Timeout during read"));
521+ logError(connection.address, timeoutException);
520522 retry(false, null);
521523 } catch (Exception e) {
522524 // This shouldn't happen, but if it does, we want to signal the callback, not let him hang indefinitively