Elffuss BraidHub

kikocis/java-driver public

Revert "Prevent concurrent retries of the same query (JAVA-449)."

This reverts commit c105d1217f71394ce166aa808d14705a35ae230b.
Changeset7704c9cd2ab647886cf4bbb9f0258b5453cf6d1ed45bdc6f97aae71b676f66d6
Authorolim7t <omichallat+github@gmail.com> · 2014-09-27 19:05 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2014-09-27 19:05 +02:00
Parentsb179b5053c92

Browse the files at this changeset

2 files changed

modified driver-core/CHANGELOG.rst +0 −1
@@ -5,7 +5,6 @@
55 ------
66
77 - [bug] Handle null pool in PooledConnection.release (JAVA-449)
8-- [bug] Prevent concurrent retries of the same query (JAVA-449)
98 - [improvement] Defunct connection on request timeout (JAVA-425)
109 - [improvement] Try next host when we get a SERVER_ERROR (JAVA-426)
1110
modified driver-core/src/main/java/com/datastax/driver/core/RequestHandler.java +18 −33
@@ -24,9 +24,8 @@
2424 import java.util.Iterator;
2525 import java.util.List;
2626 import java.util.Map;
27-import java.util.concurrent.*;
28-import java.util.concurrent.locks.Lock;
29-import java.util.concurrent.locks.ReentrantLock;
27+import java.util.concurrent.TimeUnit;
28+import java.util.concurrent.TimeoutException;
3029
3130 import com.codahale.metrics.Timer;
3231 import org.slf4j.Logger;
@@ -72,10 +71,6 @@
7271 private final Timer.Context timerContext;
7372 private final long startTime;
7473
75- // Tracks whether there is a retry already in progress
76- private final Lock retryLock = new ReentrantLock();
77- private Future<?> currentRetry; // guarded by retryLock
78-
7974 public RequestHandler(SessionManager manager, Callback callback, Statement statement) {
8075 this.manager = manager;
8176 this.callback = callback;
@@ -167,34 +162,24 @@
167162 }
168163
169164 private void retry(final boolean retryCurrent, ConsistencyLevel newConsistencyLevel) {
170- try {
171- // We lock to prevent two retries from launching concurrently
172- retryLock.lock();
173-
174- if (currentRetry != null && !currentRetry.isDone())
175- return;
176-
177- final Host h = current;
178- this.retryConsistencyLevel = newConsistencyLevel;
179-
180- // We should not retry on the current thread as this will be an IO thread.
181- currentRetry = manager.executor().submit(new Runnable() {
182- @Override
183- public void run() {
184- try {
185- if (retryCurrent) {
186- if (query(h))
187- return;
188- }
189- sendRequest();
190- } catch (Exception e) {
191- setFinalException(null, new DriverInternalError("Unexpected exception while retrying query", e));
165+ final Host h = current;
166+ this.retryConsistencyLevel = newConsistencyLevel;
167+
168+ // We should not retry on the current thread as this will be an IO thread.
169+ manager.executor().execute(new Runnable() {
170+ @Override
171+ public void run() {
172+ try {
173+ if (retryCurrent) {
174+ if (query(h))
175+ return;
192176 }
177+ sendRequest();
178+ } catch (Exception e) {
179+ setFinalException(null, new DriverInternalError("Unexpected exception while retrying query", e));
193180 }
194- });
195- } finally {
196- retryLock.unlock();
197- }
181+ }
182+ });
198183 }
199184
200185 public void cancel() {