cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [1/2] git commit: Don't send confusing info on timeouts
Date Wed, 18 Dec 2013 12:51:32 GMT
Updated Branches:
  refs/heads/cassandra-2.0 7c32ffbbf -> 1727ea773


Don't send confusing info on timeouts

patch by slebresne; reviewed by jbellis for CASSANDRA-6491


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b73178d8
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b73178d8
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b73178d8

Branch: refs/heads/cassandra-2.0
Commit: b73178d8626ec7fb404c8ded442ecff23192f14f
Parents: 079f1e8
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Dec 18 13:48:26 2013 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Dec 18 13:48:26 2013 +0100

----------------------------------------------------------------------
 CHANGES.txt                                              |  1 +
 .../cassandra/service/AbstractWriteResponseHandler.java  | 11 ++++++++++-
 src/java/org/apache/cassandra/service/ReadCallback.java  |  8 +++++++-
 src/java/org/apache/cassandra/service/StorageProxy.java  |  4 ++--
 4 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b73178d8/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5086440..a1514d0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,6 @@
 1.2.14
  * Allow executing CREATE statements multiple times (CASSANDRA-6471)
+ * Don't send confusing info with timeouts (CASSANDRA-6491)
 
 1.2.13
  * Improved error message on bad properties in DDL queries (CASSANDRA-6453)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b73178d8/src/java/org/apache/cassandra/service/AbstractWriteResponseHandler.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/AbstractWriteResponseHandler.java b/src/java/org/apache/cassandra/service/AbstractWriteResponseHandler.java
index 4df9e1f..3cd853f 100644
--- a/src/java/org/apache/cassandra/service/AbstractWriteResponseHandler.java
+++ b/src/java/org/apache/cassandra/service/AbstractWriteResponseHandler.java
@@ -88,7 +88,16 @@ public abstract class AbstractWriteResponseHandler implements IAsyncCallback
         }
 
         if (!success)
-            throw new WriteTimeoutException(writeType, consistencyLevel, ackCount(), totalBlockFor());
+        {
+            int acks = ackCount();
+            int blockedFor = totalBlockFor();
+            // It's pretty unlikely, but we can race between exiting await above and here,
so
+            // that we could now have enough acks. In that case, we "lie" on the acks count
to
+            // avoid sending confusing info to the user (see CASSANDRA-).
+            if (acks >= blockedFor)
+                acks = blockedFor - 1;
+            throw new WriteTimeoutException(writeType, consistencyLevel, acks, blockedFor);
+        }
     }
 
     protected int totalBlockFor()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b73178d8/src/java/org/apache/cassandra/service/ReadCallback.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/ReadCallback.java b/src/java/org/apache/cassandra/service/ReadCallback.java
index 64b9e76..7889039 100644
--- a/src/java/org/apache/cassandra/service/ReadCallback.java
+++ b/src/java/org/apache/cassandra/service/ReadCallback.java
@@ -97,7 +97,13 @@ public class ReadCallback<TMessage, TResolved> implements IAsyncCallback<TMessag
         }
 
         if (!success)
-            throw new ReadTimeoutException(consistencyLevel, received.get(), blockfor, resolver.isDataPresent());
+        {
+            // Same as for writes, see AbstractWriteResponseHandler
+            int acks = received.get();
+            if (resolver.isDataPresent() && acks >= blockfor)
+                acks = blockfor - 1;
+            throw new ReadTimeoutException(consistencyLevel, acks, blockfor, resolver.isDataPresent());
+        }
 
         return blockfor == 1 ? resolver.getData() : resolver.resolve();
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b73178d8/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java
index d49e59d..e6cd755 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -1013,7 +1013,7 @@ public class StorageProxy implements StorageProxyMBean
                     {
                         Tracing.trace("Timed out on digest mismatch retries");
                         int blockFor = consistency_level.blockFor(Table.open(command.getKeyspace()));
-                        throw new ReadTimeoutException(consistency_level, blockFor, blockFor,
true);
+                        throw new ReadTimeoutException(consistency_level, blockFor-1, blockFor,
true);
                     }
 
                     // retry any potential short reads
@@ -1248,7 +1248,7 @@ public class StorageProxy implements StorageProxyMBean
                         Tracing.trace("Timed out while read-repairing after receiving all
{} data and digest responses", blockFor);
                     else
                         logger.debug("Range slice timeout while read-repairing after receiving
all {} data and digest responses", blockFor);
-                    throw new ReadTimeoutException(consistency_level, blockFor, blockFor,
true);
+                    throw new ReadTimeoutException(consistency_level, blockFor-1, blockFor,
true);
                 }
                 catch (DigestMismatchException e)
                 {


Mime
View raw message