Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
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); ...