You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2016/07/20 20:40:52 UTC

[1/2] cassandra git commit: Respond with pre-v3 header for unsupported low proto versions

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.9 0b49b1776 -> 7fbe42a5a


Respond with pre-v3 header for unsupported low proto versions

Patch by Tyler Hobbs; reviewed by Sandeep Tamhankar for CASSANDRA-11464


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

Branch: refs/heads/cassandra-3.9
Commit: 904137c38419c75b9e0393d8ff4dfcf13b4710b6
Parents: 979e559
Author: Tyler Hobbs <ty...@gmail.com>
Authored: Wed Jul 20 15:37:50 2016 -0500
Committer: Tyler Hobbs <ty...@gmail.com>
Committed: Wed Jul 20 15:37:50 2016 -0500

----------------------------------------------------------------------
 CHANGES.txt                                       |  2 ++
 .../org/apache/cassandra/transport/Frame.java     |  5 ++++-
 .../org/apache/cassandra/transport/Message.java   |  8 +++++++-
 .../cassandra/transport/ProtocolException.java    | 18 ++++++++++++++++++
 .../transport/messages/ErrorMessage.java          | 13 ++++++++++++-
 5 files changed, 43 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/904137c3/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6ea39cd..9acd89e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 3.0.9
+ * Respond with v1/v2 protocol header when responding to driver that attempts
+   to connect with too low of a protocol version (CASSANDRA-11464)
  * NullPointerExpception when reading/compacting table (CASSANDRA-11988)
  * Fix problem with undeleteable rows on upgrade to new sstable format (CASSANDRA-12144)
  * Fix paging logic for deleted partitions with static columns (CASSANDRA-12107)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/904137c3/src/java/org/apache/cassandra/transport/Frame.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/Frame.java b/src/java/org/apache/cassandra/transport/Frame.java
index 363ff76..3940b47 100644
--- a/src/java/org/apache/cassandra/transport/Frame.java
+++ b/src/java/org/apache/cassandra/transport/Frame.java
@@ -175,7 +175,8 @@ public class Frame
             int version = firstByte & PROTOCOL_VERSION_MASK;
             if (version < Server.MIN_SUPPORTED_VERSION || version > Server.CURRENT_VERSION)
                 throw new ProtocolException(String.format("Invalid or unsupported protocol version (%d); the lowest supported version is %d and the greatest is %d",
-                                                          version, Server.MIN_SUPPORTED_VERSION, Server.CURRENT_VERSION));
+                                                          version, Server.MIN_SUPPORTED_VERSION, Server.CURRENT_VERSION),
+                                            version);
 
             // Wait until we have the complete header
             if (readableBytes < Header.LENGTH)
@@ -273,6 +274,8 @@ public class Frame
             header.writeByte(type.direction.addToVersion(frame.header.version));
             header.writeByte(Header.Flag.serialize(frame.header.flags));
 
+            // Continue to support writing pre-v3 headers so that we can give proper error messages to drivers that
+            // connect with the v1/v2 protocol. See CASSANDRA-11464.
             if (frame.header.version >= Server.VERSION_3)
                 header.writeShort(frame.header.streamId);
             else

http://git-wip-us.apache.org/repos/asf/cassandra/blob/904137c3/src/java/org/apache/cassandra/transport/Message.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/Message.java b/src/java/org/apache/cassandra/transport/Message.java
index 01a0794..7bfa194 100644
--- a/src/java/org/apache/cassandra/transport/Message.java
+++ b/src/java/org/apache/cassandra/transport/Message.java
@@ -150,6 +150,7 @@ public abstract class Message
     private int streamId;
     private Frame sourceFrame;
     private Map<String, ByteBuffer> customPayload;
+    protected Integer forcedProtocolVersion = null;
 
     protected Message(Type type)
     {
@@ -389,7 +390,12 @@ public abstract class Message
                     throw e;
                 }
 
-                results.add(Frame.create(message.type, message.getStreamId(), version, flags, body));
+                // if the driver attempted to connect with a protocol version lower than the minimum supported
+                // version, respond with a protocol error message with the correct frame header for that version
+                int responseVersion = message.forcedProtocolVersion == null
+                                    ? version
+                                    : message.forcedProtocolVersion;
+                results.add(Frame.create(message.type, message.getStreamId(), responseVersion, flags, body));
             }
             catch (Throwable e)
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/904137c3/src/java/org/apache/cassandra/transport/ProtocolException.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/ProtocolException.java b/src/java/org/apache/cassandra/transport/ProtocolException.java
index 9af9dc0..a589e9b 100644
--- a/src/java/org/apache/cassandra/transport/ProtocolException.java
+++ b/src/java/org/apache/cassandra/transport/ProtocolException.java
@@ -25,13 +25,31 @@ import org.apache.cassandra.exceptions.TransportException;
  */
 public class ProtocolException extends RuntimeException implements TransportException
 {
+    private final Integer attemptedLowProtocolVersion;
+
     public ProtocolException(String msg)
     {
+        this(msg, null);
+    }
+
+    public ProtocolException(String msg, Integer attemptedLowProtocolVersion)
+    {
         super(msg);
+        this.attemptedLowProtocolVersion = attemptedLowProtocolVersion;
     }
 
     public ExceptionCode code()
     {
         return ExceptionCode.PROTOCOL_ERROR;
     }
+
+    /**
+     * If the ProtocolException is due to a connection being made with a protocol version that is lower
+     * than Server.MIN_SUPPORTED_VERSION, this will return that unsupported protocol version.  Otherwise,
+     * null is returned.
+     */
+    public Integer getAttemptedLowProtocolVersion()
+    {
+        return attemptedLowProtocolVersion;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/904137c3/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java b/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java
index 021db5a..8f45d4d 100644
--- a/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java
+++ b/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java
@@ -331,7 +331,18 @@ public class ErrorMessage extends Message.Response
         }
 
         if (e instanceof TransportException)
-            return new ErrorMessage((TransportException)e, streamId);
+        {
+            ErrorMessage message = new ErrorMessage((TransportException) e, streamId);
+            if (e instanceof ProtocolException)
+            {
+                // if the driver attempted to connect with a protocol version lower than the minimum supported
+                // version, respond with a protocol error message with the correct frame header for that version
+                Integer attemptedLowProtocolVersion = ((ProtocolException) e).getAttemptedLowProtocolVersion();
+                if (attemptedLowProtocolVersion != null)
+                    message.forcedProtocolVersion = attemptedLowProtocolVersion;
+            }
+            return message;
+        }
 
         // Unexpected exception
         if (unexpectedExceptionHandler == null || !unexpectedExceptionHandler.apply(e))


[2/2] cassandra git commit: Merge branch 'cassandra-3.0' into cassandra-3.9

Posted by ty...@apache.org.
Merge branch 'cassandra-3.0' into cassandra-3.9


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

Branch: refs/heads/cassandra-3.9
Commit: 7fbe42a5a0374aa0ab60268f13346eeb7e55e3a9
Parents: 0b49b17 904137c
Author: Tyler Hobbs <ty...@gmail.com>
Authored: Wed Jul 20 15:40:11 2016 -0500
Committer: Tyler Hobbs <ty...@gmail.com>
Committed: Wed Jul 20 15:40:11 2016 -0500

----------------------------------------------------------------------
 CHANGES.txt                                       |  2 ++
 .../org/apache/cassandra/transport/Frame.java     |  5 ++++-
 .../org/apache/cassandra/transport/Message.java   |  8 +++++++-
 .../cassandra/transport/ProtocolException.java    | 18 ++++++++++++++++++
 .../transport/messages/ErrorMessage.java          | 13 ++++++++++++-
 5 files changed, 43 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7fbe42a5/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index ef80141,9acd89e..dc7a76e
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,42 -1,8 +1,44 @@@
 -3.0.9
 +3.9
 + * cqlsh: Fix handling of $$-escaped strings (CASSANDRA-12189)
 + * Fix SSL JMX requiring truststore containing server cert (CASSANDRA-12109)
 +Merged from 3.0:
+  * Respond with v1/v2 protocol header when responding to driver that attempts
+    to connect with too low of a protocol version (CASSANDRA-11464)
   * NullPointerExpception when reading/compacting table (CASSANDRA-11988)
   * Fix problem with undeleteable rows on upgrade to new sstable format (CASSANDRA-12144)
 +Merged from 2.2:
 + * Fixed cqlshlib.test.remove_test_db (CASSANDRA-12214)
 +
 +
 +3.8
 + * Fix hdr logging for single operation workloads (CASSANDRA-12145)
 + * Fix SASI PREFIX search in CONTAINS mode with partial terms (CASSANDRA-12073)
 + * Increase size of flushExecutor thread pool (CASSANDRA-12071)
 + * Partial revert of CASSANDRA-11971, cannot recycle buffer in SP.sendMessagesToNonlocalDC (CASSANDRA-11950)
 + * Upgrade netty to 4.0.39 (CASSANDRA-12032, CASSANDRA-12034)
 + * Improve details in compaction log message (CASSANDRA-12080)
 + * Allow unset values in CQLSSTableWriter (CASSANDRA-11911)
 + * Chunk cache to request compressor-compatible buffers if pool space is exhausted (CASSANDRA-11993)
 + * Remove DatabaseDescriptor dependencies from SequentialWriter (CASSANDRA-11579)
 + * Move skip_stop_words filter before stemming (CASSANDRA-12078)
 + * Support seek() in EncryptedFileSegmentInputStream (CASSANDRA-11957)
 + * SSTable tools mishandling LocalPartitioner (CASSANDRA-12002)
 + * When SEPWorker assigned work, set thread name to match pool (CASSANDRA-11966)
 + * Add cross-DC latency metrics (CASSANDRA-11596)
 + * Allow terms in selection clause (CASSANDRA-10783)
 + * Add bind variables to trace (CASSANDRA-11719)
 + * Switch counter shards' clock to timestamps (CASSANDRA-9811)
 + * Introduce HdrHistogram and response/service/wait separation to stress tool (CASSANDRA-11853)
 + * entry-weighers in QueryProcessor should respect partitionKeyBindIndexes field (CASSANDRA-11718)
 + * Support older ant versions (CASSANDRA-11807)
 + * Estimate compressed on disk size when deciding if sstable size limit reached (CASSANDRA-11623)
 + * cassandra-stress profiles should support case sensitive schemas (CASSANDRA-11546)
 + * Remove DatabaseDescriptor dependency from FileUtils (CASSANDRA-11578)
 + * Faster streaming (CASSANDRA-9766)
 + * Add prepared query parameter to trace for "Execute CQL3 prepared query" session (CASSANDRA-11425)
 + * Add repaired percentage metric (CASSANDRA-11503)
 + * Add Change-Data-Capture (CASSANDRA-8844)
 +Merged from 3.0:
   * Fix paging logic for deleted partitions with static columns (CASSANDRA-12107)
   * Wait until the message is being send to decide which serializer must be used (CASSANDRA-11393)
   * Fix migration of static thrift column names with non-text comparators (CASSANDRA-12147)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7fbe42a5/src/java/org/apache/cassandra/transport/Frame.java
----------------------------------------------------------------------