mirror of https://github.com/apache/cassandra
Don't throw assertion error on old key cache keys just skip serializing them.
patch by aweisberg; reviewed by slebresne for CASSANDRA-10778
This commit is contained in:
parent
44164bc3ab
commit
4378b58bba
|
|
@ -1,4 +1,5 @@
|
||||||
3.0.1
|
3.0.1
|
||||||
|
* Fix error when saving cached key for old format sstable (CASSANDRA-10778)
|
||||||
* Invalidate prepared statements on DROP INDEX (CASSANDRA-10758)
|
* Invalidate prepared statements on DROP INDEX (CASSANDRA-10758)
|
||||||
* Fix SELECT statement with IN restrictions on partition key,
|
* Fix SELECT statement with IN restrictions on partition key,
|
||||||
ORDER BY and LIMIT (CASSANDRA-10729)
|
ORDER BY and LIMIT (CASSANDRA-10729)
|
||||||
|
|
|
||||||
|
|
@ -455,6 +455,10 @@ public class CacheService implements CacheServiceMBean
|
||||||
{
|
{
|
||||||
public void serialize(KeyCacheKey key, DataOutputPlus out, ColumnFamilyStore cfs) throws IOException
|
public void serialize(KeyCacheKey key, DataOutputPlus out, ColumnFamilyStore cfs) throws IOException
|
||||||
{
|
{
|
||||||
|
//Don't serialize old format entries since we didn't bother to implement serialization of both for simplicity
|
||||||
|
//https://issues.apache.org/jira/browse/CASSANDRA-10778
|
||||||
|
if (!key.desc.version.storeRows()) return;
|
||||||
|
|
||||||
RowIndexEntry entry = CacheService.instance.keyCache.getInternal(key);
|
RowIndexEntry entry = CacheService.instance.keyCache.getInternal(key);
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ import org.apache.cassandra.io.sstable.format.SSTableReader;
|
||||||
import org.apache.cassandra.io.sstable.format.Version;
|
import org.apache.cassandra.io.sstable.format.Version;
|
||||||
import org.apache.cassandra.io.sstable.format.big.BigFormat;
|
import org.apache.cassandra.io.sstable.format.big.BigFormat;
|
||||||
import org.apache.cassandra.schema.KeyspaceParams;
|
import org.apache.cassandra.schema.KeyspaceParams;
|
||||||
|
import org.apache.cassandra.service.CacheService;
|
||||||
import org.apache.cassandra.service.StorageService;
|
import org.apache.cassandra.service.StorageService;
|
||||||
import org.apache.cassandra.streaming.StreamPlan;
|
import org.apache.cassandra.streaming.StreamPlan;
|
||||||
import org.apache.cassandra.streaming.StreamSession;
|
import org.apache.cassandra.streaming.StreamSession;
|
||||||
|
|
@ -238,7 +239,7 @@ public class LegacySSTableTest
|
||||||
loadLegacyTables();
|
loadLegacyTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadLegacyTables() throws IOException
|
private static void loadLegacyTables() throws Exception
|
||||||
{
|
{
|
||||||
for (String legacyVersion : legacyVersions)
|
for (String legacyVersion : legacyVersions)
|
||||||
{
|
{
|
||||||
|
|
@ -251,6 +252,8 @@ public class LegacySSTableTest
|
||||||
loadLegacyTable("legacy_%s_clust", legacyVersion);
|
loadLegacyTable("legacy_%s_clust", legacyVersion);
|
||||||
loadLegacyTable("legacy_%s_clust_counter", legacyVersion);
|
loadLegacyTable("legacy_%s_clust_counter", legacyVersion);
|
||||||
|
|
||||||
|
CacheService.instance.invalidateKeyCache();
|
||||||
|
long startCount = CacheService.instance.keyCache.size();
|
||||||
for (int ck = 0; ck < 50; ck++)
|
for (int ck = 0; ck < 50; ck++)
|
||||||
{
|
{
|
||||||
String ckValue = Integer.toString(ck) + longString;
|
String ckValue = Integer.toString(ck) + longString;
|
||||||
|
|
@ -286,6 +289,20 @@ public class LegacySSTableTest
|
||||||
Assert.assertEquals(1L, rs.one().getLong("val"));
|
Assert.assertEquals(1L, rs.one().getLong("val"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//For https://issues.apache.org/jira/browse/CASSANDRA-10778
|
||||||
|
//Validate whether the key cache successfully saves in the presence of old keys as
|
||||||
|
//well as loads the correct number of keys
|
||||||
|
long endCount = CacheService.instance.keyCache.size();
|
||||||
|
Assert.assertTrue(endCount > startCount);
|
||||||
|
CacheService.instance.keyCache.submitWrite(Integer.MAX_VALUE).get();
|
||||||
|
CacheService.instance.invalidateKeyCache();
|
||||||
|
Assert.assertEquals(startCount, CacheService.instance.keyCache.size());
|
||||||
|
CacheService.instance.keyCache.loadSaved();
|
||||||
|
if (BigFormat.instance.getVersion(legacyVersion).storeRows())
|
||||||
|
Assert.assertEquals(endCount, CacheService.instance.keyCache.size());
|
||||||
|
else
|
||||||
|
Assert.assertEquals(startCount, CacheService.instance.keyCache.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue