kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | da7a01eee420c6b0e1dcb60deddbb0da98bf11b476d9ac529813980b33d64bab |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-09-25 00:19 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-09-25 09:12 +02:00 |
| Parents | 1dbe77eef4e5 |
1 file changed
modified driver-core/src/main/java/com/datastax/driver/core/RequestHandler.java +14 −1
| @@ -28,6 +28,8 @@ | ||
| 28 | 28 | import java.util.concurrent.locks.Lock; |
| 29 | 29 | import java.util.concurrent.locks.ReentrantLock; |
| 30 | 30 | |
| 31 | +import com.google.common.util.concurrent.Futures; | |
| 32 | + | |
| 31 | 33 | import com.codahale.metrics.Timer; |
| 32 | 34 | import org.slf4j.Logger; |
| 33 | 35 | import org.slf4j.LoggerFactory; |
| @@ -115,6 +117,9 @@ | ||
| 115 | 117 | } |
| 116 | 118 | |
| 117 | 119 | private boolean query(Host host) { |
| 120 | + // Reset this because we use it later to detect if a failure occurred before or after the request was sent | |
| 121 | + connectionHandler = null; | |
| 122 | + | |
| 118 | 123 | currentPool = manager.pools.get(host); |
| 119 | 124 | if (currentPool == null || currentPool.isClosed()) |
| 120 | 125 | return false; |
| @@ -171,7 +176,15 @@ | ||
| 171 | 176 | // We lock to prevent two retries from launching concurrently |
| 172 | 177 | retryLock.lock(); |
| 173 | 178 | |
| 174 | - if (currentRetry != null && !currentRetry.isDone()) | |
| 179 | + // If we have no handler, this means the error that triggered this retry occurred while | |
| 180 | + // sending the query to Cassandra. In that case, the retry might occur synchronously with | |
| 181 | + // the error (see Connection#writeHandler). | |
| 182 | + // But if this error already occurred on a retry, the previous retry is in currentRetry | |
| 183 | + // and is not finished (since it's waiting for this method to complete), but we don't | |
| 184 | + // want to ignore the second retry. | |
| 185 | + boolean isSynchronousRetry = connectionHandler == null; | |
| 186 | + | |
| 187 | + if (currentRetry != null && !currentRetry.isDone() && !isSynchronousRetry) | |
| 175 | 188 | return; |
| 176 | 189 | |
| 177 | 190 | final Host h = current; |