You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ma...@apache.org on 2014/08/20 08:32:44 UTC

[1/3] git commit: Throw EOFException if we run out of chunks in compressed file

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 558bb7246 -> bd692ba74


Throw EOFException if we run out of chunks in compressed file

Patch by marcuse; reviewed by yukim for CASSANDRA-7664.


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

Branch: refs/heads/cassandra-2.1
Commit: 76adf0e12ed91ee7c75164872202bff29a2ad7f4
Parents: ecf1bae
Author: Marcus Eriksson <ma...@apache.org>
Authored: Tue Aug 19 11:45:57 2014 +0200
Committer: Marcus Eriksson <ma...@apache.org>
Committed: Wed Aug 20 08:21:43 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../compress/CompressedInputStream.java         | 17 +++++++++++++--
 .../compress/CompressedInputStreamTest.java     | 23 +++++++++++++++-----
 3 files changed, 35 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/76adf0e1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 304d9bf..c8f7591 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.0.10
+ * Throw EOFException if we run out of chunks in compressed datafile
+   (CASSANDRA-7664)
  * Throw InvalidRequestException when queries contain relations on entire
    collection columns (CASSANDRA-7506)
  * Fix PRSI handling of CQL3 row markers for row cleanup (CASSANDRA-7787)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76adf0e1/src/java/org/apache/cassandra/streaming/compress/CompressedInputStream.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/compress/CompressedInputStream.java b/src/java/org/apache/cassandra/streaming/compress/CompressedInputStream.java
index 698c2fe..ef019c2 100644
--- a/src/java/org/apache/cassandra/streaming/compress/CompressedInputStream.java
+++ b/src/java/org/apache/cassandra/streaming/compress/CompressedInputStream.java
@@ -58,6 +58,8 @@ public class CompressedInputStream extends InputStream
     // raw checksum bytes
     private final byte[] checksumBytes = new byte[4];
 
+    private static final byte[] POISON_PILL = new byte[0];
+
     private long totalCompressedBytesRead;
     private final boolean hasPostCompressionAdlerChecksums;
 
@@ -83,7 +85,10 @@ public class CompressedInputStream extends InputStream
         {
             try
             {
-                decompress(dataBuffer.take());
+                byte[] compressedWithCRC = dataBuffer.take();
+                if (compressedWithCRC == POISON_PILL)
+                    throw new EOFException("No chunk available");
+                decompress(compressedWithCRC);
             }
             catch (InterruptedException e)
             {
@@ -162,7 +167,15 @@ public class CompressedInputStream extends InputStream
 
                 int bufferRead = 0;
                 while (bufferRead < readLength)
-                    bufferRead += source.read(compressedWithCRC, bufferRead, readLength - bufferRead);
+                {
+                    int r = source.read(compressedWithCRC, bufferRead, readLength - bufferRead);
+                    if (r < 0)
+                    {
+                        dataBuffer.put(POISON_PILL);
+                        return; // throw exception where we consume dataBuffer
+                    }
+                    bufferRead += r;
+                }
                 dataBuffer.put(compressedWithCRC);
             }
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76adf0e1/test/unit/org/apache/cassandra/streaming/compress/CompressedInputStreamTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/streaming/compress/CompressedInputStreamTest.java b/test/unit/org/apache/cassandra/streaming/compress/CompressedInputStreamTest.java
index 027c84c..532b506 100644
--- a/test/unit/org/apache/cassandra/streaming/compress/CompressedInputStreamTest.java
+++ b/test/unit/org/apache/cassandra/streaming/compress/CompressedInputStreamTest.java
@@ -19,6 +19,7 @@ package org.apache.cassandra.streaming.compress;
 
 import java.io.ByteArrayInputStream;
 import java.io.DataInputStream;
+import java.io.EOFException;
 import java.io.File;
 import java.io.RandomAccessFile;
 import java.util.*;
@@ -42,18 +43,23 @@ public class CompressedInputStreamTest
     @Test
     public void testCompressedRead() throws Exception
     {
-        testCompressedReadWith(new long[]{0L});
-        testCompressedReadWith(new long[]{1L});
-        testCompressedReadWith(new long[]{100L});
+        testCompressedReadWith(new long[]{0L}, false);
+        testCompressedReadWith(new long[]{1L}, false);
+        testCompressedReadWith(new long[]{100L}, false);
 
-        testCompressedReadWith(new long[]{1L, 122L, 123L, 124L, 456L});
+        testCompressedReadWith(new long[]{1L, 122L, 123L, 124L, 456L}, false);
     }
 
+    @Test(expected = EOFException.class)
+    public void testTruncatedRead() throws Exception
+    {
+        testCompressedReadWith(new long[]{1L, 122L, 123L, 124L, 456L}, true);
+    }
     /**
      * @param valuesToCheck array of longs of range(0-999)
      * @throws Exception
      */
-    private void testCompressedReadWith(long[] valuesToCheck) throws Exception
+    private void testCompressedReadWith(long[] valuesToCheck, boolean testTruncate) throws Exception
     {
         assert valuesToCheck != null && valuesToCheck.length > 0;
 
@@ -95,6 +101,13 @@ public class CompressedInputStreamTest
         }
         f.close();
 
+        if (testTruncate)
+        {
+            byte [] actuallyRead = new byte[50];
+            System.arraycopy(toRead, 0, actuallyRead, 0, 50);
+            toRead = actuallyRead;
+        }
+
         // read buffer using CompressedInputStream
         CompressionInfo info = new CompressionInfo(chunks, param);
         CompressedInputStream input = new CompressedInputStream(new ByteArrayInputStream(toRead), info, true);


[2/3] git commit: Merge branch 'cassandra-2.0' into cassandra-2.1.0

Posted by ma...@apache.org.
Merge branch 'cassandra-2.0' into cassandra-2.1.0

Conflicts:
	CHANGES.txt


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

Branch: refs/heads/cassandra-2.1
Commit: 39b81967f18e1210a64fa98a1b84037235a09b9c
Parents: af188ed 76adf0e
Author: Marcus Eriksson <ma...@apache.org>
Authored: Wed Aug 20 08:25:16 2014 +0200
Committer: Marcus Eriksson <ma...@apache.org>
Committed: Wed Aug 20 08:25:16 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../compress/CompressedInputStream.java         | 17 +++++++++++++--
 .../compress/CompressedInputStreamTest.java     | 23 +++++++++++++++-----
 3 files changed, 35 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/39b81967/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 183d849,c8f7591..873eb78
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,37 -1,20 +1,39 @@@
 -2.0.10
 +2.1.0
 + * (cqlsh) Fix COPY FROM handling of null/empty primary key
 +   values (CASSANDRA-7792)
 + * Fix ordering of static cells (CASSANDRA-7763)
 +Merged from 2.0:
+  * Throw EOFException if we run out of chunks in compressed datafile
+    (CASSANDRA-7664)
 - * Throw InvalidRequestException when queries contain relations on entire
 -   collection columns (CASSANDRA-7506)
   * Fix PRSI handling of CQL3 row markers for row cleanup (CASSANDRA-7787)
 - * (cqlsh) enable CTRL-R history search with libedit (CASSANDRA-7577)
   * Fix dropping collection when it's the last regular column (CASSANDRA-7744)
   * Properly reject operations on list index with conditions (CASSANDRA-7499)
 - * (Hadoop) allow ACFRW to limit nodes to local DC (CASSANDRA-7252)
 +Merged from 1.2:
 + * Validate empty cell names from counter updates (CASSANDRA-7798)
 +
 +
 +2.1.0-rc6
 + * Fix OOM issue from netty caching over time (CASSANDRA-7743)
 + * json2sstable couldn't import JSON for CQL table (CASSANDRA-7477)
 + * Invalidate all caches on table drop (CASSANDRA-7561)
 + * Skip strict endpoint selection for ranges if RF == nodes (CASSANRA-7765)
 + * Fix Thrift range filtering without 2ary index lookups (CASSANDRA-7741)
 + * Add tracing entries about concurrent range requests (CASSANDRA-7599)
 + * (cqlsh) Fix DESCRIBE for NTS keyspaces (CASSANDRA-7729)
 + * Remove netty buffer ref-counting (CASSANDRA-7735)
 + * Pass mutated cf to index updater for use by PRSI (CASSANDRA-7742)
 + * Include stress yaml example in release and deb (CASSANDRA-7717)
 + * workaround for netty issue causing corrupted data off the wire (CASSANDRA-7695)
 + * cqlsh DESC CLUSTER fails retrieving ring information (CASSANDRA-7687)
 + * Fix binding null values inside UDT (CASSANDRA-7685)
 + * Fix UDT field selection with empty fields (CASSANDRA-7670)
 + * Bogus deserialization of static cells from sstable (CASSANDRA-7684)
 + * Fix NPE on compaction leftover cleanup for dropped table (CASSANDRA-7770)
 +Merged from 2.0:
   * (cqlsh) Wait up to 10 sec for a tracing session (CASSANDRA-7222)
   * Fix NPE in FileCacheService.sizeInBytes (CASSANDRA-7756)
 - * (cqlsh) cqlsh should automatically disable tracing when selecting
 -   from system_traces (CASSANDRA-7641)
 - * (Hadoop) Add CqlOutputFormat (CASSANDRA-6927)
 - * Don't depend on cassandra config for nodetool ring (CASSANDRA-7508)
 - * (cqlsh) Fix failing cqlsh formatting tests (CASSANDRA-7703)
 + * Remove duplicates from StorageService.getJoiningNodes (CASSANDRA-7478)
 + * Clone token map outside of hot gossip loops (CASSANDRA-7758)
   * Fix MS expiring map timeout for Paxos messages (CASSANDRA-7752)
   * Do not flush on truncate if durable_writes is false (CASSANDRA-7750)
   * Give CRR a default input_cql Statement (CASSANDRA-7226)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/39b81967/test/unit/org/apache/cassandra/streaming/compress/CompressedInputStreamTest.java
----------------------------------------------------------------------


[3/3] git commit: Merge branch 'cassandra-2.1.0' into cassandra-2.1

Posted by ma...@apache.org.
Merge branch 'cassandra-2.1.0' into cassandra-2.1


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

Branch: refs/heads/cassandra-2.1
Commit: bd692ba74499428b0ee5c6defbb86966f3b30c12
Parents: 558bb72 39b8196
Author: Marcus Eriksson <ma...@apache.org>
Authored: Wed Aug 20 08:25:28 2014 +0200
Committer: Marcus Eriksson <ma...@apache.org>
Committed: Wed Aug 20 08:25:28 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../compress/CompressedInputStream.java         | 17 +++++++++++++--
 .../compress/CompressedInputStreamTest.java     | 23 +++++++++++++++-----
 3 files changed, 35 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/bd692ba7/CHANGES.txt
----------------------------------------------------------------------