From: Timo Sirainen Date: Thu, 3 May 2018 14:06:04 +0000 (+0300) Subject: cassandra: Use fallback_consistency on more types of errors X-Git-Tag: 2.3.2.rc1~115 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bbe09dffc40d3589f106a66b7c441ae1f4824684;p=thirdparty%2Fdovecot%2Fcore.git cassandra: Use fallback_consistency on more types of errors This could allow for example read_consistency=local-quorum with read_fallback_consistency=quorum, so most of the time the reads are from local datacenter, but in case it has problems you can switch to other datacenters. --- diff --git a/src/lib-sql/driver-cassandra.c b/src/lib-sql/driver-cassandra.c index b4c397b0a3..667fef32e3 100644 --- a/src/lib-sql/driver-cassandra.c +++ b/src/lib-sql/driver-cassandra.c @@ -913,11 +913,25 @@ static void counters_inc_error(struct cassandra_db *db, CassError error) static bool query_error_want_fallback(CassError error) { switch (error) { + case CASS_ERROR_LIB_WRITE_ERROR: + case CASS_ERROR_LIB_REQUEST_TIMED_OUT: + /* Communication problems on client side. Maybe it will work + with fallback consistency? */ + return TRUE; case CASS_ERROR_LIB_NO_HOSTS_AVAILABLE: /* The client library couldn't connect to enough Cassandra nodes. The error message text is the same as for CASS_ERROR_SERVER_UNAVAILABLE. */ return TRUE; + case CASS_ERROR_SERVER_SERVER_ERROR: + case CASS_ERROR_SERVER_OVERLOADED: + case CASS_ERROR_SERVER_IS_BOOTSTRAPPING: + case CASS_ERROR_SERVER_READ_TIMEOUT: + case CASS_ERROR_SERVER_READ_FAILURE: + case CASS_ERROR_SERVER_WRITE_FAILURE: + /* Servers are having trouble. Maybe with fallback consistency + we can reach non-troubled servers? */ + return TRUE; case CASS_ERROR_SERVER_UNAVAILABLE: /* Cassandra server knows that there aren't enough nodes available. "All hosts in current policy attempted and were