Merge branch 'cassandra-3.0' into trunk
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/16ea55b0 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/16ea55b0 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/16ea55b0 Branch: refs/heads/trunk Commit: 16ea55b0ef962795891c21d0dd0bdb0b6d816c9b Parents: 73ad99d bf7d433 Author: Marcus Eriksson <[email protected]> Authored: Tue Apr 26 08:30:58 2016 +0200 Committer: Marcus Eriksson <[email protected]> Committed: Tue Apr 26 09:32:12 2016 +0200 ---------------------------------------------------------------------- CHANGES.txt | 2 + .../compaction/LeveledCompactionStrategy.java | 15 ++++- .../db/compaction/LeveledManifest.java | 15 ++++- .../LongLeveledCompactionStrategyTest.java | 64 ++++++++++++++++++++ 4 files changed, 92 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/16ea55b0/CHANGES.txt ---------------------------------------------------------------------- diff --cc CHANGES.txt index 0c96c44,7d6760b..cd9220b --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -80,13 -23,10 +80,15 @@@ Merged from 2.1 * cqlsh COPY FROM fails with []{} chars in UDT/tuple fields/values (CASSANDRA-11633) * clqsh: COPY FROM throws TypeError with Cython extensions enabled (CASSANDRA-11574) * cqlsh: COPY FROM ignores NULL values in conversion (CASSANDRA-11549) + * Validate levels when building LeveledScanner to avoid overlaps with orphaned sstables (CASSANDRA-9935) + -3.0.5 +3.5 + * StaticTokenTreeBuilder should respect posibility of duplicate tokens (CASSANDRA-11525) + * Correctly fix potential assertion error during compaction (CASSANDRA-11353) + * Avoid index segment stitching in RAM which lead to OOM on big SSTable files (CASSANDRA-11383) + * Fix clustering and row filters for LIKE queries on clustering columns (CASSANDRA-11397) +Merged from 3.0: * Fix rare NPE on schema upgrade from 2.x to 3.x (CASSANDRA-10943) * Improve backoff policy for cqlsh COPY FROM (CASSANDRA-11320) * Improve IF NOT EXISTS check in CREATE INDEX (CASSANDRA-11131) http://git-wip-us.apache.org/repos/asf/cassandra/blob/16ea55b0/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/16ea55b0/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/16ea55b0/test/long/org/apache/cassandra/db/compaction/LongLeveledCompactionStrategyTest.java ---------------------------------------------------------------------- diff --cc test/long/org/apache/cassandra/db/compaction/LongLeveledCompactionStrategyTest.java index fe1871b,79497aa..24a9cea --- a/test/long/org/apache/cassandra/db/compaction/LongLeveledCompactionStrategyTest.java +++ b/test/long/org/apache/cassandra/db/compaction/LongLeveledCompactionStrategyTest.java @@@ -134,4 -141,61 +141,61 @@@ public class LongLeveledCompactionStrat } } } + + @Test + public void testLeveledScanner() throws Exception + { + testParallelLeveledCompaction(); + Keyspace keyspace = Keyspace.open(KEYSPACE1); + ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF_STANDARDLVL); + store.disableAutoCompaction(); - - LeveledCompactionStrategy lcs = (LeveledCompactionStrategy)store.getCompactionStrategyManager().getStrategies().get(1); ++ CompactionStrategyManager mgr = store.getCompactionStrategyManager(); ++ LeveledCompactionStrategy lcs = (LeveledCompactionStrategy) mgr.getStrategies().get(1).get(0); + + ByteBuffer value = ByteBuffer.wrap(new byte[10 * 1024]); // 10 KB value + + // Adds 10 partitions + for (int r = 0; r < 10; r++) + { + DecoratedKey key = Util.dk(String.valueOf(r)); + UpdateBuilder builder = UpdateBuilder.create(store.metadata, key); + for (int c = 0; c < 10; c++) + builder.newRow("column" + c).add("val", value); + + Mutation rm = new Mutation(builder.build()); + rm.apply(); + } + + //Flush sstable + store.forceBlockingFlush(); + + Iterable<SSTableReader> allSSTables = store.getSSTables(SSTableSet.LIVE); + for (SSTableReader sstable : allSSTables) + { + if (sstable.getSSTableLevel() == 0) + { + System.out.println("Mutating L0-SSTABLE level to L1 to simulate a bug: " + sstable.getFilename()); + sstable.descriptor.getMetadataSerializer().mutateLevel(sstable.descriptor, 1); + sstable.reloadSSTableMetadata(); + } + } + + try (AbstractCompactionStrategy.ScannerList scannerList = lcs.getScanners(Lists.newArrayList(allSSTables))) + { + //Verify that leveled scanners will always iterate in ascending order (CASSANDRA-9935) + for (ISSTableScanner scanner : scannerList.scanners) + { + DecoratedKey lastKey = null; + while (scanner.hasNext()) + { + UnfilteredRowIterator row = scanner.next(); + if (lastKey != null) + { + assertTrue("row " + row.partitionKey() + " received out of order wrt " + lastKey, row.partitionKey().compareTo(lastKey) >= 0); + } + lastKey = row.partitionKey(); + } + } + } + } }
