Paulo Motta created CASSANDRA-7290:
--------------------------------------

             Summary: Compaction strategy is not reloaded when compaction 
strategy options is updated
                 Key: CASSANDRA-7290
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-7290
             Project: Cassandra
          Issue Type: Bug
          Components: Core
            Reporter: Paulo Motta
             Fix For: 1.2.17, 2.0.9


The AbstractCompactionStrategy constructor receives an options map on its 
constructor:
{code:java}
    protected AbstractCompactionStrategy(ColumnFamilyStore cfs, Map<String, 
String> options)
    {
        assert cfs != null;
        this.cfs = cfs;
        this.options = options;
    ...
{code}
This map is currently the same reference as 
CFMetadata.compactionStrategyOptions, so ColumnFamilyStore.reload() does not 
reload the compaction strategy when a compaction strategy option changes:
{code:java}
    private void maybeReloadCompactionStrategy()
    {
        // Check if there is a need for reloading
        if 
(metadata.compactionStrategyClass.equals(compactionStrategy.getClass()) 
            && 
metadata.compactionStrategyOptions.equals(compactionStrategy.options)) 
//metadata.compactionStrategyOptions == compactionStrategy.options, so 
compaction is never reloaded
            return;
{code}

I spotted this in my test, when I tried changing the value of 
"unchecked_tombstone_compaction" from false to true and calling 
ColumnFamilyStore.reload() was not reloading the compaction strategy. I don't 
know if ColumnFamilyStore.reload() is only called during tests, or also 
whenever the schema changes. 

In order to fix the bug, I made AbstractCompactionStrategy.options an 
ImmutableMap, so if CFMetadata.compactionStrategyOptions is updated, 
ColumnFamilyStore.maybeReloadCompactionStrategy will actually reload the 
compaction strategy:
{code:java}
    protected AbstractCompactionStrategy(ColumnFamilyStore cfs, Map<String, 
String> options)
    {
        assert cfs != null;
        this.cfs = cfs;
        this.options = ImmutableMap.copyOf(options);
    ...
{code}




--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to