cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefa...@apache.org
Subject [3/6] cassandra git commit: Avoid sstable corrupt exception due to dropped static column
Date Mon, 10 Oct 2016 01:56:00 GMT
Avoid sstable corrupt exception due to dropped static column

Patch by Stefania Alborghetti; reviewed by Carl Yeksigian for CASSANDRA-12582


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

Branch: refs/heads/trunk
Commit: 2f0e365dc495336332e174b30e2d15e56fc344e2
Parents: e9ea5e0
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Fri Sep 23 13:52:02 2016 +0800
Committer: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Committed: Mon Oct 10 09:50:30 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt                                           |  1 +
 src/java/org/apache/cassandra/config/CFMetaData.java  | 14 ++++++++++++--
 .../org/apache/cassandra/db/SerializationHeader.java  |  3 ++-
 3 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2f0e365d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 894113a..a517995 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.10
+ * Avoid sstable corrupt exception due to dropped static column (CASSANDRA-12582)
  * Make stress use client mode to avoid checking commit log size on startup (CASSANDRA-12478)
  * Fix exceptions with new vnode allocation (CASSANDRA-12715)
  * Unify drain and shutdown processes (CASSANDRA-12509)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2f0e365d/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java
index c0f8d2d..a702902 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -665,11 +665,19 @@ public final class CFMetaData
         return droppedColumns;
     }
 
+    public ColumnDefinition getDroppedColumnDefinition(ByteBuffer name)
+    {
+        return getDroppedColumnDefinition(name, false);
+    }
+
     /**
      * Returns a "fake" ColumnDefinition corresponding to the dropped column {@code name}
      * of {@code null} if there is no such dropped column.
+     *
+     * @param name - the column name
+     * @param isStatic - whether the column was a static column, if known
      */
-    public ColumnDefinition getDroppedColumnDefinition(ByteBuffer name)
+    public ColumnDefinition getDroppedColumnDefinition(ByteBuffer name, boolean isStatic)
     {
         DroppedColumn dropped = droppedColumns.get(name);
         if (dropped == null)
@@ -679,7 +687,9 @@ public final class CFMetaData
         // it means that it's a dropped column from before 3.0, and in that case using
         // BytesType is fine for what we'll be using it for, even if that's a hack.
         AbstractType<?> type = dropped.type == null ? BytesType.instance : dropped.type;
-        return ColumnDefinition.regularDef(this, name, type);
+        return isStatic
+               ? ColumnDefinition.staticDef(this, name, type)
+               : ColumnDefinition.regularDef(this, name, type);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2f0e365d/src/java/org/apache/cassandra/db/SerializationHeader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SerializationHeader.java b/src/java/org/apache/cassandra/db/SerializationHeader.java
index 0fd1281..19dad95 100644
--- a/src/java/org/apache/cassandra/db/SerializationHeader.java
+++ b/src/java/org/apache/cassandra/db/SerializationHeader.java
@@ -331,7 +331,8 @@ public class SerializationHeader
                     // If we don't find the definition, it could be we have data for a dropped
column, and we shouldn't
                     // fail deserialization because of that. So we grab a "fake" ColumnDefinition
that ensure proper
                     // deserialization. The column will be ignore later on anyway.
-                    column = metadata.getDroppedColumnDefinition(name);
+                    boolean isStatic = staticColumns.containsKey(name);
+                    column = metadata.getDroppedColumnDefinition(name, isStatic);
                     if (column == null)
                         throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name)
+ " during deserialization");
                 }


Mime
View raw message