Merge branch 'cassandra-2.0' into trunk Conflicts: CHANGES.txt src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/3aaa0295 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/3aaa0295 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/3aaa0295 Branch: refs/heads/trunk Commit: 3aaa0295c884b3c8d8e6ab5e3cd90e26cc77d1a3 Parents: 4334f99 15ee948 Author: Marcus Eriksson <marc...@apache.org> Authored: Thu Feb 13 08:46:59 2014 +0100 Committer: Marcus Eriksson <marc...@apache.org> Committed: Thu Feb 13 08:46:59 2014 +0100 ---------------------------------------------------------------------- CHANGES.txt | 4 +++- .../db/compaction/LeveledManifest.java | 23 ++++---------------- 2 files changed, 7 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/3aaa0295/CHANGES.txt ---------------------------------------------------------------------- diff --cc CHANGES.txt index a45df89,9509a76..139eb06 --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,37 -1,3 +1,36 @@@ +2.1 + * add listsnapshots command to nodetool (CASSANDRA-5742) + * Introduce AtomicBTreeColumns (CASSANDRA-6271) + * Multithreaded commitlog (CASSANDRA-3578) + * allocate fixed index summary memory pool and resample cold index summaries + to use less memory (CASSANDRA-5519) + * Removed multithreaded compaction (CASSANDRA-6142) + * Parallelize fetching rows for low-cardinality indexes (CASSANDRA-1337) + * change logging from log4j to logback (CASSANDRA-5883) + * switch to LZ4 compression for internode communication (CASSANDRA-5887) + * Stop using Thrift-generated Index* classes internally (CASSANDRA-5971) + * Remove 1.2 network compatibility code (CASSANDRA-5960) + * Remove leveled json manifest migration code (CASSANDRA-5996) + * Remove CFDefinition (CASSANDRA-6253) + * Use AtomicIntegerFieldUpdater in RefCountedMemory (CASSANDRA-6278) + * User-defined types for CQL3 (CASSANDRA-5590) + * Use of o.a.c.metrics in nodetool (CASSANDRA-5871, 6406) + * Batch read from OTC's queue and cleanup (CASSANDRA-1632) + * Secondary index support for collections (CASSANDRA-4511, 6383) + * SSTable metadata(Stats.db) format change (CASSANDRA-6356) + * Push composites support in the storage engine + (CASSANDRA-5417, CASSANDRA-6520) + * Add snapshot space used to cfstats (CASSANDRA-6231) + * Add cardinality estimator for key count estimation (CASSANDRA-5906) + * CF id is changed to be non-deterministic. Data dir/key cache are created + uniquely for CF id (CASSANDRA-5202) + * New counters implementation (CASSANDRA-6504) + * Replace UnsortedColumns, EmptyColumns, TreeMapBackedSortedColumns with new + ArrayBackedSortedColumns (CASSANDRA-6630, CASSANDRA-6662, CASSANDRA-6690) + * Add option to use row cache with a given amount of rows (CASSANDRA-5357) + * Avoid repairing already repaired data (CASSANDRA-5351) + * Reject counter updates with USING TTL/TIMESTAMP (CASSANDRA-6649) + - 2.0.6 * Add compatibility for Hadoop 0.2.x (CASSANDRA-5201) * Fix EstimatedHistogram races (CASSANDRA-6682) http://git-wip-us.apache.org/repos/asf/cassandra/blob/3aaa0295/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/db/compaction/LeveledManifest.java index cab726d,a78a867..05b838d --- a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java +++ b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java @@@ -103,93 -105,14 +103,76 @@@ public class LeveledManifes public synchronized void add(SSTableReader reader) { + if (!hasRepairedData && reader.isRepaired()) + { + // this is the first repaired sstable we get - we need to + // rebuild the entire manifest, unrepaired data should be + // in unrepairedL0. Note that we keep the sstable level in + // the sstable metadata since we are likely to be able to + // re-add it at a good level later (during anticompaction + // for example). + hasRepairedData = true; + rebuildManifestAfterFirstRepair(); + } + int level = reader.getSSTableLevel(); - assert level < generations.length : "Invalid level " + level + " out of " + (generations.length - 1); - logDistribution(); + if (hasRepairedData && !reader.isRepaired()) + { + logger.debug("Adding unrepaired {} to unrepaired L0", reader); + unrepairedL0.add(reader); + } + else + { + assert level < generations.length : "Invalid level " + level + " out of " + (generations.length - 1); + logDistribution(); + if (canAddSSTable(reader)) + { + // adding the sstable does not cause overlap in the level + logger.debug("Adding {} to L{}", reader, level); + generations[level].add(reader); + } + else + { + // this can happen if: + // * a compaction has promoted an overlapping sstable to the given level, or + // * we promote a non-repaired sstable to repaired at level > 0, but an ongoing compaction + // was also supposed to add an sstable at the given level. + // + // The add(..):ed sstable will be sent to level 0 + try + { + reader.descriptor.getMetadataSerializer().mutateLevel(reader.descriptor, 0); + reader.reloadSSTableMetadata(); + } + catch (IOException e) + { + logger.error("Could not change sstable level - adding it at level 0 anyway, we will find it at restart.", e); + } + generations[0].add(reader); + } + } - logger.debug("Adding {} to L{}", reader, level); - generations[level].add(reader); + } + + + /** + * Since we run standard LCS when we have no repaired data + * we need to move all sstables from the leveling + * to unrepairedL0. + */ + private void rebuildManifestAfterFirstRepair() + { + for (int i = 1; i < getAllLevelSize().length; i++) + { + + for (SSTableReader sstable : getLevel(i)) + { + generations[i] = new ArrayList<>(); + add(sstable); + } + } } - /** - * if the number of SSTables in the current compacted set *by itself* exceeds the target level's - * (regardless of the level's current contents), find an empty level instead - */ - private int skipLevels(int newLevel, Iterable<SSTableReader> added) - { - // Note that we now check if the sstables included in the compaction, *before* the compaction, fit in the next level. - // This is needed since we need to decide before the actual compaction what level they will be in. - // This should be safe, we might skip levels where the compacted data could have fit but that should be ok. - while (maxBytesForLevel(newLevel) < SSTableReader.getTotalBytes(added) - && getLevel(newLevel + 1).isEmpty()) - { - newLevel++; - } - return newLevel; - } - public synchronized void replace(Collection<SSTableReader> removed, Collection<SSTableReader> added) { assert !removed.isEmpty(); // use add() instead of promote when adding new sstables