You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2013/10/31 14:43:14 UTC

[2/3] git commit: Skip loading corrupt key cache patch by Mikhail Stepura; reviewed by jbellis for CASSANDRA-6260

Skip loading corrupt key cache
patch by Mikhail Stepura; reviewed by jbellis for CASSANDRA-6260


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

Branch: refs/heads/trunk
Commit: 7015a7a6bfc5cf7239d89a9213719d16d3367303
Parents: 47b8fc4
Author: Jonathan Ellis <jb...@apache.org>
Authored: Thu Oct 31 08:43:00 2013 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Thu Oct 31 08:43:00 2013 -0500

----------------------------------------------------------------------
 CHANGES.txt                                             |  1 +
 src/java/org/apache/cassandra/service/CacheService.java | 10 +++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7015a7a6/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index ecec238..9a44d8e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.3
+ * Skip loading corrupt key cache (CASSANDRA-6260)
  * Fixes for compacting larger-than-memory rows (CASSANDRA-6274)
  * Compact hottest sstables first and optionally omit coldest from
    compaction entirely (CASSANDRA-6109)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7015a7a6/src/java/org/apache/cassandra/service/CacheService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CacheService.java b/src/java/org/apache/cassandra/service/CacheService.java
index ab8b72d..f626e17 100644
--- a/src/java/org/apache/cassandra/service/CacheService.java
+++ b/src/java/org/apache/cassandra/service/CacheService.java
@@ -25,7 +25,6 @@ import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
@@ -48,7 +47,6 @@ import org.apache.cassandra.db.RowIndexEntry;
 import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.io.sstable.SSTableReader;
-import org.apache.cassandra.io.sstable.SSTableReader.Operator;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.Pair;
@@ -349,7 +347,13 @@ public class CacheService implements CacheServiceMBean
 
         public Future<Pair<KeyCacheKey, RowIndexEntry>> deserialize(DataInputStream input, ColumnFamilyStore cfs) throws IOException
         {
-            ByteBuffer key = ByteBufferUtil.readWithLength(input);
+            int keyLength = input.readInt();
+            if (keyLength > FBUtilities.MAX_UNSIGNED_SHORT)
+            {
+                throw new IOException(String.format("Corrupted key cache. Key length of %d is longer than maximum of %d",
+                                                    keyLength, FBUtilities.MAX_UNSIGNED_SHORT));
+            }
+            ByteBuffer key = ByteBufferUtil.read(input, keyLength);
             int generation = input.readInt();
             SSTableReader reader = findDesc(generation, cfs.getSSTables());
             input.readBoolean(); // backwards compatibility for "promoted indexes" boolean