Fix remaining dtest failures caused by CASSANDRA-8143

patch by Branimir Lambov; reviewed by Aleksey Yeschenko for
CASSANDRA-8143
This commit is contained in:
Branimir Lambov 2015-08-04 16:26:18 +03:00 committed by Aleksey Yeschenko
parent be0eebd20b
commit 64e93a76d8
6 changed files with 19 additions and 28 deletions

View File

@ -276,14 +276,12 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
}
}
// FIXME: this is wrong, JMX should never update live CFMetaData objects
public void setCrcCheckChance(double crcCheckChance)
{
try
{
// TODO: this doesn't affect sstables being written
for (SSTableReader sstable : keyspace.getAllSSTables(SSTableSet.CANONICAL))
if (sstable.compression)
sstable.getCompressionMetadata().parameters.setCrcCheckChance(crcCheckChance);
metadata.params.compression.setCrcCheckChance(crcCheckChance);
}
catch (ConfigurationException e)
{

View File

@ -71,10 +71,10 @@ class Helpers
* A convenience method for encapsulating this action over multiple SSTableReader with exception-safety
* @return accumulate if not null (with any thrown exception attached), or any thrown exception otherwise
*/
static void setupKeyCache(Iterable<SSTableReader> readers)
static void setupOnline(Iterable<SSTableReader> readers)
{
for (SSTableReader reader : readers)
reader.setupKeyCache();
reader.setupOnline();
}
/**
@ -97,16 +97,6 @@ class Helpers
return accumulate;
}
/**
* A convenience method for encapsulating this action over multiple SSTableReader with exception-safety
* @return accumulate if not null (with any thrown exception attached), or any thrown exception otherwise
*/
static void setupKeycache(Iterable<SSTableReader> readers)
{
for (SSTableReader reader : readers)
reader.setupKeyCache();
}
/**
* assert that none of these readers have been replaced
*/

View File

@ -350,7 +350,7 @@ public class LifecycleTransaction extends Transactional.AbstractTransactional
staged.update.add(reader);
identities.add(reader.instanceId);
if (!isOffline())
reader.setupKeyCache();
reader.setupOnline();
}
/**

View File

@ -177,7 +177,7 @@ public class Tracker
public void addInitialSSTables(Iterable<SSTableReader> sstables)
{
if (!isDummy())
setupKeycache(sstables);
setupOnline(sstables);
apply(updateLiveSet(emptySet(), sstables));
maybeFail(updateSizeTracking(emptySet(), sstables, null));
// no notifications or backup necessary
@ -341,7 +341,7 @@ public class Tracker
return;
}
sstable.setupKeyCache();
sstable.setupOnline();
// back up before creating a new Snapshot (which makes the new one eligible for compaction)
maybeIncrementallyBackup(sstable);

View File

@ -222,7 +222,7 @@ public class SSTableRewriter extends Transactional.AbstractTransactional impleme
final List<DecoratedKey> invalidateKeys = new ArrayList<>();
invalidateKeys.addAll(cachedKeys.keySet());
newReader.setupKeyCache();
newReader.setupOnline();
for (Map.Entry<DecoratedKey, RowIndexEntry> cacheKey : cachedKeys.entrySet())
newReader.cacheKey(cacheKey.getKey(), cacheKey.getValue());

View File

@ -635,12 +635,19 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
return dfile.path();
}
public void setupKeyCache()
public void setupOnline()
{
// under normal operation we can do this at any time, but SSTR is also used outside C* proper,
// e.g. by BulkLoader, which does not initialize the cache. As a kludge, we set up the cache
// here when we know we're being wired into the rest of the server infrastructure.
keyCache = CacheService.instance.keyCache;
// ensure secondary index compression metadata is linked to the parent metadata.
if (compression && metadata.isIndex())
{
getCompressionMetadata().parameters.setLiveMetadata(
Schema.instance.getCFMetaData(metadata.ksName, metadata.getParentColumnFamilyName()));
}
}
public boolean isKeyCacheSetup()
@ -1287,13 +1294,7 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
if (!compression)
throw new IllegalStateException(this + " is not compressed");
CompressionMetadata cmd = ((ICompressedFile) dfile).getMetadata();
// We need the parent cf metadata
String cfName = metadata.isIndex() ? metadata.getParentColumnFamilyName() : metadata.cfName;
cmd.parameters.setLiveMetadata(Schema.instance.getCFMetaData(metadata.ksName, cfName));
return cmd;
return ((ICompressedFile) dfile).getMetadata();
}
/**
@ -2050,6 +2051,8 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
{
tidy.setup(this, trackHotness);
this.readMeter = tidy.global.readMeter;
if (compression)
getCompressionMetadata().parameters.setLiveMetadata(metadata);
}
@VisibleForTesting