You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2014/01/30 18:21:45 UTC
git commit: Fix SSTableScanner potentially skipping rows during
cleanup
Updated Branches:
refs/heads/cassandra-2.0 cd91cf974 -> 81fcc33d9
Fix SSTableScanner potentially skipping rows during cleanup
patch by slebresne; reviewed by thobbs for CASSANDRA-6638
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/81fcc33d
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/81fcc33d
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/81fcc33d
Branch: refs/heads/cassandra-2.0
Commit: 81fcc33d9d483d27d38348f7aed582f3621cedbd
Parents: cd91cf9
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Thu Jan 30 18:17:16 2014 +0100
Committer: Sylvain Lebresne <sy...@datastax.com>
Committed: Thu Jan 30 18:19:34 2014 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../cassandra/io/sstable/SSTableScanner.java | 6 ++++
.../io/sstable/SSTableScannerTest.java | 30 ++++++++++++++++++++
3 files changed, 37 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/81fcc33d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a059d84..531ac15 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -15,6 +15,7 @@
* Fix ArrayIndexOutOfBoundsException in 2ndary index query (CASSANDRA-6470)
* Release sstables upon rebuilding 2i (CASSANDRA-6635)
* Add AbstractCompactionStrategy.startup() method (CASSANDRA-6637)
+ * SSTableScanner may skip rows during cleanup (CASSANDRA-6638)
Merged from 1.2:
* fsync compression metadata (CASSANDRA-6531)
* Validate CF existence on execution for prepared statement (CASSANDRA-6535)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/81fcc33d/src/java/org/apache/cassandra/io/sstable/SSTableScanner.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableScanner.java b/src/java/org/apache/cassandra/io/sstable/SSTableScanner.java
index 703b6e9..7a87879 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableScanner.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableScanner.java
@@ -116,7 +116,13 @@ public class SSTableScanner implements ICompactionScanner
long indexPosition = sstable.getIndexScanPosition(currentRange.left);
// -1 means the key is before everything in the sstable. So just start from the beginning.
if (indexPosition == -1)
+ {
+ // Note: this method shouldn't assume we're at the start of the sstable already (see #6638) and
+ // the seeks are no-op anyway if we are.
+ ifile.seek(0);
+ dfile.seek(0);
return;
+ }
ifile.seek(indexPosition);
try
http://git-wip-us.apache.org/repos/asf/cassandra/blob/81fcc33d/test/unit/org/apache/cassandra/io/sstable/SSTableScannerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/SSTableScannerTest.java b/test/unit/org/apache/cassandra/io/sstable/SSTableScannerTest.java
index c17fb71..67d9d2c 100644
--- a/test/unit/org/apache/cassandra/io/sstable/SSTableScannerTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/SSTableScannerTest.java
@@ -284,4 +284,34 @@ public class SSTableScannerTest extends SchemaLoader
scanner = sstable.getScanner(new ArrayList<Range<Token>>(), null);
assertFalse(scanner.hasNext());
}
+
+ @Test
+ public void testSingleKeyMultipleRanges()
+ {
+ Keyspace keyspace = Keyspace.open(KEYSPACE);
+ ColumnFamilyStore store = keyspace.getColumnFamilyStore(TABLE);
+ store.clearUnsafe();
+
+ // disable compaction while flushing
+ store.disableAutoCompaction();
+
+ insertRowWithKey(205);
+ store.forceBlockingFlush();
+
+ assertEquals(1, store.getSSTables().size());
+ SSTableReader sstable = store.getSSTables().iterator().next();
+
+ // full range scan
+ SSTableScanner fullScanner = sstable.getScanner();
+ assertScanContainsRanges(fullScanner, 205, 205);
+
+ // scan three ranges separately
+ ICompactionScanner scanner = sstable.getScanner(makeRanges(
+ 101, 109,
+ 201, 209),
+ null);
+
+ // Test for #6638 bug
+ assertScanContainsRanges(scanner, 205, 205);
+ }
}