Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-7290

Compaction strategy is not reloaded when compaction strategy options is updated

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • 2.0.9
    • Local/Compaction
    • None
    • Normal

    Description

      The AbstractCompactionStrategy constructor receives an options map on its constructor:

          protected AbstractCompactionStrategy(ColumnFamilyStore cfs, Map<String, String> options)
          {
              assert cfs != null;
              this.cfs = cfs;
              this.options = options;
          ...
      

      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:

          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;
      

      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:

          protected AbstractCompactionStrategy(ColumnFamilyStore cfs, Map<String, String> options)
          {
              assert cfs != null;
              this.cfs = cfs;
              this.options = ImmutableMap.copyOf(options);
          ...
      

      Attachments

        Activity

          People

            pauloricardomg Paulo Motta
            pauloricardomg Paulo Motta
            Paulo Motta
            Marcus Eriksson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: