diff --git a/CHANGES.txt b/CHANGES.txt index 1d9f20b04b..4c2b8363c7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 1.1.2 + * Use correct partitioner when saving + loading caches (CASSANDRA-4331) * Check schema before trying to export sstable (CASSANDRA-2760) * Raise a meaningful exception instead of NPE when PFS encounters an unconfigured node + no default (CASSANDRA-4349) diff --git a/src/java/org/apache/cassandra/cache/AutoSavingCache.java b/src/java/org/apache/cassandra/cache/AutoSavingCache.java index 7eed2a02ca..004e46e822 100644 --- a/src/java/org/apache/cassandra/cache/AutoSavingCache.java +++ b/src/java/org/apache/cassandra/cache/AutoSavingCache.java @@ -36,6 +36,7 @@ import org.apache.cassandra.db.compaction.CompactionInfo; import org.apache.cassandra.db.compaction.CompactionManager; import org.apache.cassandra.db.compaction.OperationType; import org.apache.cassandra.db.DecoratedKey; +import org.apache.cassandra.dht.IPartitioner; import org.apache.cassandra.io.util.FileUtils; import org.apache.cassandra.io.util.SequentialWriter; import org.apache.cassandra.service.CacheService; @@ -92,7 +93,7 @@ public class AutoSavingCache extends InstrumentingCache readSaved(String ksName, String cfName) + public Set readSaved(String ksName, String cfName, IPartitioner partitioner) { File path = getCachePath(ksName, cfName); Set keys = new TreeSet(); @@ -114,7 +115,7 @@ public class AutoSavingCache extends InstrumentingCache savedKeys = caching == Caching.NONE || caching == Caching.ROWS_ONLY ? Collections.emptySet() - : CacheService.instance.keyCache.readSaved(table.name, columnFamily); + : CacheService.instance.keyCache.readSaved(table.name, columnFamily, partitioner); Directories.SSTableLister sstables = directories.sstableLister().skipCompacted(true).skipTemporary(true); data.addInitialSSTables(SSTableReader.batchOpen(sstables.list().entrySet(), savedKeys, data, metadata, this.partitioner)); @@ -412,7 +412,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean // results are sorted on read (via treeset) because there are few reads and many writes and reads only happen at startup int cachedRowsRead = 0; - for (DecoratedKey key : rowCache.readSaved(table.name, columnFamily)) + for (DecoratedKey key : rowCache.readSaved(table.name, columnFamily, partitioner)) { ColumnFamily data = getTopLevelColumns(QueryFilter.getIdentityFilter(key, new QueryPath(columnFamily)), Integer.MIN_VALUE, diff --git a/test/unit/org/apache/cassandra/db/RowCacheTest.java b/test/unit/org/apache/cassandra/db/RowCacheTest.java index e6b4578226..7535968a6d 100644 --- a/test/unit/org/apache/cassandra/db/RowCacheTest.java +++ b/test/unit/org/apache/cassandra/db/RowCacheTest.java @@ -133,7 +133,7 @@ public class RowCacheTest extends SchemaLoader { CompactionManager.instance.disableAutoCompaction(); - ColumnFamilyStore store = Table.open(KEYSPACE).getColumnFamilyStore(COLUMN_FAMILY); + ColumnFamilyStore cfs = Table.open(KEYSPACE).getColumnFamilyStore(COLUMN_FAMILY); // empty the cache CacheService.instance.invalidateRowCache(); @@ -153,6 +153,6 @@ public class RowCacheTest extends SchemaLoader // empty the cache again to make sure values came from disk CacheService.instance.invalidateRowCache(); assert CacheService.instance.rowCache.size() == 0; - assert CacheService.instance.rowCache.readSaved(KEYSPACE, COLUMN_FAMILY).size() == (keysToSave == Integer.MAX_VALUE ? totalKeys : keysToSave); + assert CacheService.instance.rowCache.readSaved(KEYSPACE, COLUMN_FAMILY, cfs.partitioner).size() == (keysToSave == Integer.MAX_VALUE ? totalKeys : keysToSave); } }