kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 00adccdfeee8432f8ff740440a3798eda3f1df9d729a9e39d17cd413c5415854 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2015-01-29 23:27 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-01-30 15:41 +01:00 |
| Parents | ee4de8e6237f |
3 files changed
modified driver-core/CHANGELOG.rst +2 −0
| @@ -7,6 +7,8 @@ | ||
| 7 | 7 | - [bug] Prevent race between cancellation and query completion (JAVA-614) |
| 8 | 8 | - [bug] Prevent cancel and timeout from cancelling unrelated ResponseHandler if |
| 9 | 9 | streamId was already released and reused (JAVA-632). |
| 10 | +- [bug] Fix issue when newly opened pool fails before we could mark the node UP | |
| 11 | + (JAVA-642) | |
| 10 | 12 | |
| 11 | 13 | |
| 12 | 14 | 2.0.9: |
modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +11 −1
| @@ -276,9 +276,19 @@ | ||
| 276 | 276 | // sure the "suspected" mechanism work as expected |
| 277 | 277 | Host host = factory.manager.metadata.getHost(address); |
| 278 | 278 | if (host != null) { |
| 279 | + | |
| 280 | + // If the host was reconnecting, and this error happens right after we opened a connection pool, but | |
| 281 | + // before we could mark the node UP, we don't want to go through the SUSPECTED state, because that can | |
| 282 | + // lead to a race condition that leaves the node UP with a closed pool. | |
| 283 | + boolean belongsToReconnectingPool = host.state != Host.State.UP && | |
| 284 | + this instanceof PooledConnection && | |
| 285 | + (((PooledConnection)this).pool == null || !((PooledConnection)this).pool.isClosed()); | |
| 286 | + | |
| 287 | + boolean markSuspected = isInitialized && !belongsToReconnectingPool; | |
| 288 | + | |
| 279 | 289 | // This will trigger onDown, including when the defunct Connection is part of a reconnection attempt, which is redundant. |
| 280 | 290 | // This is not too much of a problem since calling onDown on a node that is already down has no effect. |
| 281 | - boolean isDown = factory.manager.signalConnectionFailure(host, ce, host.wasJustAdded(), isInitialized); | |
| 291 | + boolean isDown = factory.manager.signalConnectionFailure(host, ce, host.wasJustAdded(), markSuspected); | |
| 282 | 292 | notifyOwnerWhenDefunct(isDown); |
| 283 | 293 | } |
| 284 | 294 |
modified driver-core/src/main/java/com/datastax/driver/core/PooledConnection.java +1 −1
| @@ -23,7 +23,7 @@ | ||
| 23 | 23 | */ |
| 24 | 24 | class PooledConnection extends Connection { |
| 25 | 25 | |
| 26 | - private final HostConnectionPool pool; | |
| 26 | + final HostConnectionPool pool; | |
| 27 | 27 | |
| 28 | 28 | /** Used in {@link HostConnectionPool} to handle races between two threads trying to trash the same connection */ |
| 29 | 29 | final AtomicBoolean markForTrash = new AtomicBoolean(); |