kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | ff3be45397085809c8de3b8fa84a804a06105d5fb4b15dbe5606657a81edad6d |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-12-21 17:33 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-12-21 17:37 +01:00 |
| Parents | 08e9c0652731, 091573a39423 |
2 files changed
modified driver-core/CHANGELOG.rst +4 −0
| @@ -23,6 +23,8 @@ | ||
| 23 | 23 | (JAVA-593) |
| 24 | 24 | - [bug] Ensure state change notifications for a given host are handled serially |
| 25 | 25 | (JAVA-594) |
| 26 | +- [bug] Ensure control connection reconnects when control host is removed | |
| 27 | + (JAVA-597) | |
| 26 | 28 | |
| 27 | 29 | |
| 28 | 30 | 2.1.3: |
| @@ -167,6 +169,8 @@ | ||
| 167 | 169 | (JAVA-593) |
| 168 | 170 | - [bug] Ensure state change notifications for a given host are handled serially |
| 169 | 171 | (JAVA-594) |
| 172 | +- [bug] Ensure control connection reconnects when control host is removed | |
| 173 | + (JAVA-597) | |
| 170 | 174 | |
| 171 | 175 | |
| 172 | 176 | 2.0.8: |
modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +15 −3
| @@ -110,6 +110,9 @@ | ||
| 110 | 110 | // reconnectInternal only propagate those if we've not decided on the protocol version yet, |
| 111 | 111 | // which should only happen on the initial connection and thus in connect() but never here. |
| 112 | 112 | throw new AssertionError(); |
| 113 | + } catch (Exception e) { | |
| 114 | + logger.error("[Control connection] Unknown error during reconnection, scheduling retry", e); | |
| 115 | + backgroundReconnect(-1); | |
| 113 | 116 | } |
| 114 | 117 | } |
| 115 | 118 | |
| @@ -159,9 +162,9 @@ | ||
| 159 | 162 | |
| 160 | 163 | private void signalError() { |
| 161 | 164 | Connection connection = connectionRef.get(); |
| 162 | - if (connection != null && connection.isDefunct()) { | |
| 163 | - // If the connection was marked as defunct, this already reported the | |
| 164 | - // node down, which will trigger a reconnect. | |
| 165 | + if (connection != null && connection.isDefunct() && cluster.metadata.getHost(connection.address) != null) { | |
| 166 | + // If the connection was marked as defunct and the host hadn't left, this already reported the | |
| 167 | + // host down, which will trigger a reconnect. | |
| 165 | 168 | return; |
| 166 | 169 | } |
| 167 | 170 | // If the connection is not defunct, or the host has left, just reconnect manually |
| @@ -691,6 +694,15 @@ | ||
| 691 | 694 | |
| 692 | 695 | @Override |
| 693 | 696 | public void onRemove(Host host) { |
| 697 | + Connection current = connectionRef.get(); | |
| 698 | + if (logger.isDebugEnabled()) | |
| 699 | + logger.debug("[Control connection] {} has been removed, currently connected to {}", host, current == null ? "nobody" : current.address); | |
| 700 | + | |
| 701 | + // Schedule a reconnection if that was our control host | |
| 702 | + if (current != null && current.address.equals(host.getSocketAddress())) { | |
| 703 | + backgroundReconnect(0); | |
| 704 | + } | |
| 705 | + | |
| 694 | 706 | refreshNodeListAndTokenMap(); |
| 695 | 707 | } |
| 696 | 708 | } |