racker/node-cassandra-client — pull request #58 by Kami (2012-12-21 08:43:22+00:00)
Title: Fail fast on Thrift connection errors

This change properly propagated Thrift connection errors to the callback passed to `Connection.execute` function.

Currently if an error is emitted on a Thrift connection we just (incorrectly) log it, but we don't do anything about it. This means if a Thrift connection error occurs we will wait for a query timeout before calling `Connection.execute` callback with timeout error.

As a consequence, this delays fail-over to a next connection when using `PooledConnection` for up to `query_timeout` ms which (defaults to 5 seconds).

With my change, `Connection.execute` callback is called with a Thrift error as soon as an error has been emitted which means that fail-over is usually instantaneous.

So far I did two manual tests with a single connection in a pool:

1. Killing a Cassandra server and trying to execute a query
2. Using drain

In both cases `error` is correctly emitted on the Thrift connection and `Connection.execute` callback is called with Thrift error almost instantaneously compared to before master when it takes 5 seconds.