]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
cassandra: Use fallback_consistency on more types of errors
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 3 May 2018 14:06:04 +0000 (17:06 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 18 May 2018 07:46:11 +0000 (10:46 +0300)
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.

src/lib-sql/driver-cassandra.c

index b6a3f2a301e79f84fa83ca336b9eb5127e1c1f24..c533260e31ddbc9194267997a70a75ede13d32d7 100644 (file)
@@ -911,11 +911,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