Optimize connection use on reconnection

Description

When a background reconnection attempt succeeds, we immediately trash the connection that was just established, and then proceed to mark the node UP, which will recreate a pool to the node.

As noted in code comments, this is inefficient because that first connection could be kept open and used by the pool. This is important for clusters with a huge number of clients, where even short-lived connections can have an impact on the server (see the comments in ).

A bit of refactoring is necessary, because the first connection is a Connection, but the pool uses the subclass PooledConnection, and we can't magically turn an object into an instance of its subclass. Using composition over inheritance might help.

Environment

None

Pull Requests

None

Activity

Show:
Olivier Michallat
October 15, 2014, 4:11 PM

There is now a special case in Connection#defunct to avoid re-triggering onDown when we get an error on a reconnect (f42f825), so take that into account too.

Olivier Michallat
December 16, 2014, 2:16 PM

Rescheduled to 2.0.10 due to urgent 2.0.9 bugfix release. The fix is available at https://github.com/datastax/java-driver/commit/6eada94.

Olivier Michallat
January 13, 2015, 2:39 PM

The fix can be re-applied by cherry-picking commits 36a330f, 6eada94 and cf3ba3e. I'll wait for to be merged on 2.0, to handle all the merges in one pass.

Olivier Michallat
February 18, 2015, 8:19 PM

To do on top of that patch: also reuse the connection to prepare queries, see JAVA-658.

Fixed

Assignee

Olivier Michallat

Reporter

Olivier Michallat

Labels

None

PM Priority

None

Affects versions

Fix versions

Pull Request

None

Doc Impact

None

Size

None

External issue ID

None

External issue ID

None

Components

Priority

Minor
Configure