Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-14439

ClassCastException with mixed 1.2.18 + 2.0.17 environment

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Low
    • Resolution: Won't Fix
    • Fix Version/s: None
    • Component/s: Legacy/Core
    • Labels:
    • Environment:

      Mixed 1.2.18  + 2.0.17 environment, used temporarily during incremental migration process.

    • Severity:
      Low
    • Since Version:

      Description

      During mixed versions tests I've discovered that mixed 1.2.18  + 2.0.17 environment gives the following exception on 2.0.17 node:

      java.lang.ClassCastException: org.apache.cassandra.db.SliceByNamesReadCommand cannot be cast to org.apache.cassandra.db.SliceFromReadCommand
      at org.apache.cassandra.db.SliceFromReadCommandSerializer.serializedSize(SliceFromReadCommand.java:242)
      at org.apache.cassandra.db.ReadCommandSerializer.serializedSize(ReadCommand.java:204)
      at org.apache.cassandra.db.ReadCommandSerializer.serializedSize(ReadCommand.java:134)
      at org.apache.cassandra.net.MessageOut.serialize(MessageOut.java:116)
      at org.apache.cassandra.net.OutboundTcpConnection.writeInternal(OutboundTcpConnection.java:251)
      at org.apache.cassandra.net.OutboundTcpConnection.writeConnected(OutboundTcpConnection.java:203)
      at org.apache.cassandra.net.OutboundTcpConnection.run(OutboundTcpConnection.java:151)
      

      The exception is caused by inconsistent commandType handling in ReadCommandSerializer(),

              out.writeByte(newCommand.commandType.serializedValue);
              switch (command.commandType) /// <----------- WHY NOT newCommand.commandType -- DCI ???
              {
                  case GET_BY_NAMES:
                      SliceByNamesReadCommand.serializer.serialize(newCommand, superColumn, out, version);
                      break;
                  case GET_SLICES:
                      SliceFromReadCommand.serializer.serialize(newCommand, superColumn, out, version);
                      break;
                  default:
                      throw new AssertionError();
              }
      

      Proposed fix (also attached as a patch):

      diff --git a/src/java/org/apache/cassandra/db/ReadCommand.java b/src/java/org/apache/cassandra/db/ReadCommand.java
      index cadcd7d..f2153e8 100644
      --- a/src/java/org/apache/cassandra/db/ReadCommand.java
      +++ b/src/java/org/apache/cassandra/db/ReadCommand.java
      @@ -153,7 +153,7 @@ class ReadCommandSerializer implements IVersionedSerializer<ReadCommand>
               }
       
               out.writeByte(newCommand.commandType.serializedValue);
      -        switch (command.commandType)
      +        switch (newCommand.commandType)
               {
                   case GET_BY_NAMES:
                       SliceByNamesReadCommand.serializer.serialize(newCommand, superColumn, out, version);
      @@ -196,7 +196,7 @@ class ReadCommandSerializer implements IVersionedSerializer<ReadCommand>
                   }
               }
       
      -        switch (command.commandType)
      +        switch (newCommand.commandType)
               {
                   case GET_BY_NAMES:
                       return 1 + SliceByNamesReadCommand.serializer.serializedSize(newCommand, superColumn, version);
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dcieslak Dariusz Cieslak
                Reporter:
                dcieslak Dariusz Cieslak
                Authors:
                Dariusz Cieslak
                Reviewers:
                Michael Semb Wever
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: