Author: jbellis Date: Wed Mar 9 02:58:26 2011 New Revision: 1079650 URL: http://svn.apache.org/viewvc?rev=1079650&view=rev Log: add asserts to make sure we don't write zero-length rows; see CASSANDRA-2296
Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/CompactionManager.java cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/LazilyCompactedRow.java cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/PrecompactedRow.java cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/CompactionManager.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/CompactionManager.java?rev=1079650&r1=1079649&r2=1079650&view=diff ============================================================================== --- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/CompactionManager.java (original) +++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/CompactionManager.java Wed Mar 9 02:58:26 2011 @@ -1122,6 +1122,7 @@ public class CompactionManager implement public void write(PageCacheInformer out) throws IOException { + assert row.dataSize != 0; out.writeLong(row.dataSize); row.echoData(out); } Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/LazilyCompactedRow.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/LazilyCompactedRow.java?rev=1079650&r1=1079649&r2=1079650&view=diff ============================================================================== --- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/LazilyCompactedRow.java (original) +++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/LazilyCompactedRow.java Wed Mar 9 02:58:26 2011 @@ -98,6 +98,7 @@ public class LazilyCompactedRow extends if (rows.size() == 1 && !shouldPurge && rows.get(0).sstable.descriptor.isLatestVersion && !forceDeserialize) { SSTableIdentityIterator row = rows.get(0); + assert row.dataSize != 0; out.writeLong(row.dataSize); row.echoData(out); return; @@ -106,7 +107,9 @@ public class LazilyCompactedRow extends DataOutputBuffer clockOut = new DataOutputBuffer(); ColumnFamily.serializer().serializeCFInfo(emptyColumnFamily, clockOut); - out.writeLong(headerBuffer.getLength() + clockOut.getLength() + columnSerializedSize); + long dataSize = headerBuffer.getLength() + clockOut.getLength() + columnSerializedSize; + assert dataSize != 0; + out.writeLong(dataSize); out.write(headerBuffer.getData(), 0, headerBuffer.getLength()); out.write(clockOut.getData(), 0, clockOut.getLength()); out.writeInt(columnCount); Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/PrecompactedRow.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/PrecompactedRow.java?rev=1079650&r1=1079649&r2=1079650&view=diff ============================================================================== --- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/PrecompactedRow.java (original) +++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/PrecompactedRow.java Wed Mar 9 02:58:26 2011 @@ -118,6 +118,7 @@ public class PrecompactedRow extends Abs public void write(PageCacheInformer out) throws IOException { + assert buffer.getLength() != 0; out.writeLong(buffer.getLength()); List<Pair<Integer, Integer>> pageCacheMarkers = buffer.getPageCacheMarkers(); Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java?rev=1079650&r1=1079649&r2=1079650&view=diff ============================================================================== --- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java (original) +++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java Wed Mar 9 02:58:26 2011 @@ -147,7 +147,9 @@ public class SSTableWriter extends SSTab // seek back and write the row size (not including the size Long itself) long endPosition = dataFile.getFilePointer(); dataFile.seek(sizePosition); - dataFile.writeLong(endPosition - (sizePosition + 8)); + long dataSize = endPosition - (sizePosition + 8); + assert dataSize != 0; + dataFile.writeLong(dataSize); // finally, reset for next row dataFile.seek(endPosition); afterAppend(decoratedKey, startPosition);