changeset 20306:2417b436d73c

cassandra: Try fallback_consistency also for write timeout failures.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sat, 11 Jun 2016 17:13:12 +0300
parents 18f158c1b25d
children 981debc87f26
files src/lib-sql/driver-cassandra.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-sql/driver-cassandra.c	Tue Jun 07 08:50:12 2016 +0300
+++ b/src/lib-sql/driver-cassandra.c	Sat Jun 11 17:13:12 2016 +0300
@@ -707,7 +707,16 @@
 		result->error = i_strdup_printf("Query '%s' failed: %.*s",
 						result->query,
 						(int)errsize, errmsg);
-		if (error == CASS_ERROR_SERVER_UNAVAILABLE &&
+		/* unavailable = cassandra server knows that there aren't
+		   enough nodes available.
+
+		   write timeout = cassandra server couldn't reach all the
+		   needed nodes. this may be because it hasn't yet detected
+		   that the servers are down, or because the servers are just
+		   too busy. we'll try the fallback consistency to avoid
+		   unnecessary temporary errors. */
+		if ((error == CASS_ERROR_SERVER_UNAVAILABLE ||
+		     error == CASS_ERROR_SERVER_WRITE_TIMEOUT) &&
 		    result->fallback_consistency != result->consistency) {
 			/* retry with fallback consistency */
 			query_resend_with_fallback(result);