kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | e4b963e48dcf307907a68a036f33dad6e2b411f067fda3d37723b00ecb976573 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-12-14 19:02 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-12-14 20:57 +01:00 |
| Parents | 45a7e96c0cf9 |
2 files changed
modified driver-core/CHANGELOG.rst +2 −0
| @@ -12,6 +12,8 @@ | ||
| 12 | 12 | - [bug] Avoid deadlock when multiple connections to the same host get write |
| 13 | 13 | errors (JAVA-557) |
| 14 | 14 | - [improvement] Make shuffle=true the default for TokenAwarePolicy (JAVA-504) |
| 15 | +- [bug] Fix bug when SUSPECT reconnection succeeds, but one of the pooled | |
| 16 | + connections fails while bringing the node back up (JAVA-577) | |
| 15 | 17 | |
| 16 | 18 | |
| 17 | 19 | 2.0.8: |
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +17 −4
| @@ -26,6 +26,7 @@ | ||
| 26 | 26 | import java.util.concurrent.atomic.AtomicReference; |
| 27 | 27 | |
| 28 | 28 | import com.google.common.annotations.VisibleForTesting; |
| 29 | +import com.google.common.base.Function; | |
| 29 | 30 | import com.google.common.base.Predicates; |
| 30 | 31 | import com.google.common.collect.*; |
| 31 | 32 | import com.google.common.util.concurrent.*; |
| @@ -1501,15 +1502,23 @@ | ||
| 1501 | 1502 | host.initialReconnectionAttempt.set(executor.submit(new ExceptionCatchingRunnable() { |
| 1502 | 1503 | @Override |
| 1503 | 1504 | public void runMayThrow() throws InterruptedException, ExecutionException { |
| 1505 | + boolean success; | |
| 1504 | 1506 | try { |
| 1505 | 1507 | // TODO: as for the ReconnectionHandler, we could avoid "wasting" this connection |
| 1506 | 1508 | connectionFactory.open(host).closeAsync(); |
| 1507 | 1509 | // Note that we want to do the pool creation on this thread because we want that |
| 1508 | 1510 | // when onUp return, the host is ready for querying |
| 1509 | 1511 | onUp(host, MoreExecutors.sameThreadExecutor()); |
| 1512 | + // If one of the connections in onUp failed, it signaled the error and triggerd onDown, | |
| 1513 | + // but onDown aborted because this reconnection attempt was in progress (JAVA-577). | |
| 1514 | + // Test the state now to check than onUp succeeded (we know it's up-to-date since onUp was | |
| 1515 | + // executed synchronously). | |
| 1516 | + success = host.state == Host.State.UP; | |
| 1510 | 1517 | } catch (Exception e) { |
| 1511 | - onDown(host, false, true); | |
| 1518 | + success = false; | |
| 1512 | 1519 | } |
| 1520 | + if (!success) | |
| 1521 | + onDown(host, false, true); | |
| 1513 | 1522 | } |
| 1514 | 1523 | })); |
| 1515 | 1524 | |
| @@ -1531,19 +1540,23 @@ | ||
| 1531 | 1540 | if (isClosed()) |
| 1532 | 1541 | return; |
| 1533 | 1542 | |
| 1534 | - // If we're SUSPECT and not the task validating the suspection, then some other task is | |
| 1543 | + // If we're SUSPECT and not the task validating the suspicion, then some other task is | |
| 1535 | 1544 | // already checking to verify if the node is really down (or if it's simply that the |
| 1536 | 1545 | // connections where broken). So just skip this in that case. |
| 1537 | - if (!isSuspectedVerification && host.state == Host.State.SUSPECT) | |
| 1546 | + if (!isSuspectedVerification && host.state == Host.State.SUSPECT) { | |
| 1547 | + logger.debug("Aborting onDown because a reconnection is running on SUSPECT host {}", host); | |
| 1538 | 1548 | return; |
| 1549 | + } | |
| 1539 | 1550 | |
| 1540 | 1551 | // Note: we don't want to skip that method if !host.isUp() because we set isUp |
| 1541 | 1552 | // late in onUp, and so we can rely on isUp if there is an error during onUp. |
| 1542 | 1553 | // But if there is a reconnection attempt in progress already, then we know |
| 1543 | 1554 | // we've already gone through that method since the last successful onUp(), so |
| 1544 | 1555 | // we're good skipping it. |
| 1545 | - if (host.reconnectionAttempt.get() != null) | |
| 1556 | + if (host.reconnectionAttempt.get() != null) { | |
| 1557 | + logger.debug("Aborting onDown because a reconnection is running on DOWN host {}", host); | |
| 1546 | 1558 | return; |
| 1559 | + } | |
| 1547 | 1560 | |
| 1548 | 1561 | // Remember if we care about this node at all. We must call this before |
| 1549 | 1562 | // we've signalled the load balancing policy, since most policy will always |