diff --git a/CHANGES.txt b/CHANGES.txt index 3ea8849c71..9cf5271b6c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,6 +13,7 @@ * Change order of directory searching for c*.in.sh (CASSANDRA-3983) * Add tool to reset SSTable level (CASSANDRA-5271) * Allow custom configuration loader (CASSANDRA-5045) + * Remove memory emergency pressure valve logic (CASSANDRA-3534) 1.2.3 diff --git a/NEWS.txt b/NEWS.txt index b68a5f4173..250545ed4b 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -15,7 +15,11 @@ Upgrading --------- - Replication and strategy options do not accept unknown options anymore. This was already the case for CQL3 in 1.2 but this is now the case for - thrift to. + thrift too. + - reduce_cache_sizes_at, reduce_cache_capacity_to, and + flush_largest_memtables_at options have been removed from cassandra.yaml. + - CacheServiceMBean.reduceCacheSizes() has been removed. + Use CacheServiceMBean.set{Key,Row}CacheCapacityInMB() instead. 1.2.3 diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml index 2691e47d35..b3ef2cd6d2 100644 --- a/conf/cassandra.yaml +++ b/conf/cassandra.yaml @@ -237,31 +237,6 @@ seed_provider: # Ex: ",," - seeds: "127.0.0.1" -# emergency pressure valve: each time heap usage after a full (CMS) -# garbage collection is above this fraction of the max, Cassandra will -# flush the largest memtables. -# -# Set to 1.0 to disable. Setting this lower than -# CMSInitiatingOccupancyFraction is not likely to be useful. -# -# RELYING ON THIS AS YOUR PRIMARY TUNING MECHANISM WILL WORK POORLY: -# it is most effective under light to moderate load, or read-heavy -# workloads; under truly massive write load, it will often be too -# little, too late. -flush_largest_memtables_at: 0.75 - -# emergency pressure valve #2: the first time heap usage after a full -# (CMS) garbage collection is above this fraction of the max, -# Cassandra will reduce cache maximum _capacity_ to the given fraction -# of the current _size_. Should usually be set substantially above -# flush_largest_memtables_at, since that will have less long-term -# impact on the system. -# -# Set to 1.0 to disable. Setting this lower than -# CMSInitiatingOccupancyFraction is not likely to be useful. -reduce_cache_sizes_at: 0.85 -reduce_cache_capacity_to: 0.6 - # For workloads with more data than can fit in memory, Cassandra's # bottleneck will be reads that need to fetch data from # disk. "concurrent_reads" should be set to (16 * number_of_drives) in diff --git a/src/java/org/apache/cassandra/cache/AutoSavingCache.java b/src/java/org/apache/cassandra/cache/AutoSavingCache.java index 7e4bb776e9..072385e7a5 100644 --- a/src/java/org/apache/cassandra/cache/AutoSavingCache.java +++ b/src/java/org/apache/cassandra/cache/AutoSavingCache.java @@ -176,19 +176,6 @@ public class AutoSavingCache extends InstrumentingCache 0) - { - int newCapacity = (int) (DatabaseDescriptor.getReduceCacheCapacityTo() * weightedSize()); - - logger.warn(String.format("Reducing %s capacity from %d to %s to reduce memory pressure", - cacheType, getCapacity(), newCapacity)); - - setCapacity(newCapacity); - } - } - public class Writer extends CompactionInfo.Holder { private final Set keys; diff --git a/src/java/org/apache/cassandra/config/Config.java b/src/java/org/apache/cassandra/config/Config.java index 2bc1b0e40d..ce8660933a 100644 --- a/src/java/org/apache/cassandra/config/Config.java +++ b/src/java/org/apache/cassandra/config/Config.java @@ -144,9 +144,6 @@ public class Config public InternodeCompression internode_compression = InternodeCompression.none; - public Double flush_largest_memtables_at = 1.0; - public Double reduce_cache_sizes_at = 1.0; - public double reduce_cache_capacity_to = 0.6; public int hinted_handoff_throttle_in_kb = 1024; public int max_hints_delivery_threads = 1; public boolean compaction_preheat_key_cache = true; diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java index fc49bcd1d7..98f671d041 100644 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@ -37,7 +37,6 @@ import org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions; import org.apache.cassandra.db.ColumnFamilyStore; import org.apache.cassandra.db.DefsTable; import org.apache.cassandra.db.SystemTable; -import org.apache.cassandra.db.Table; import org.apache.cassandra.dht.IPartitioner; import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.cassandra.io.FSWriteError; @@ -1107,21 +1106,6 @@ public class DatabaseDescriptor return conf.client_encryption_options; } - public static double getFlushLargestMemtablesAt() - { - return conf.flush_largest_memtables_at; - } - - public static double getReduceCacheSizesAt() - { - return conf.reduce_cache_sizes_at; - } - - public static double getReduceCacheCapacityTo() - { - return conf.reduce_cache_capacity_to; - } - public static int getHintedHandoffThrottleInKB() { return conf.hinted_handoff_throttle_in_kb; diff --git a/src/java/org/apache/cassandra/service/CacheService.java b/src/java/org/apache/cassandra/service/CacheService.java index b0aa693038..e389a5d755 100644 --- a/src/java/org/apache/cassandra/service/CacheService.java +++ b/src/java/org/apache/cassandra/service/CacheService.java @@ -296,22 +296,6 @@ public class CacheService implements CacheServiceMBean return keyCache.size(); } - public void reduceCacheSizes() - { - reduceRowCacheSize(); - reduceKeyCacheSize(); - } - - public void reduceRowCacheSize() - { - rowCache.reduceCacheSize(); - } - - public void reduceKeyCacheSize() - { - keyCache.reduceCacheSize(); - } - public void saveCaches() throws ExecutionException, InterruptedException { List> futures = new ArrayList>(2); diff --git a/src/java/org/apache/cassandra/service/CacheServiceMBean.java b/src/java/org/apache/cassandra/service/CacheServiceMBean.java index 8b8adf2a31..8e2f530aea 100644 --- a/src/java/org/apache/cassandra/service/CacheServiceMBean.java +++ b/src/java/org/apache/cassandra/service/CacheServiceMBean.java @@ -41,11 +41,6 @@ public interface CacheServiceMBean public void setKeyCacheCapacityInMB(long capacity); - /** - * sets each cache's maximum capacity to "reduce_cache_capacity_to" of its current size - */ - public void reduceCacheSizes(); - /** * save row and key caches * diff --git a/src/java/org/apache/cassandra/service/GCInspector.java b/src/java/org/apache/cassandra/service/GCInspector.java index bca8e1ce70..9961bf9a21 100644 --- a/src/java/org/apache/cassandra/service/GCInspector.java +++ b/src/java/org/apache/cassandra/service/GCInspector.java @@ -31,7 +31,6 @@ import javax.management.ObjectName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.io.sstable.SSTableDeletingTask; import org.apache.cassandra.utils.StatusLogger; @@ -50,8 +49,6 @@ public class GCInspector final List beans = new ArrayList(); final MemoryMXBean membean = ManagementFactory.getMemoryMXBean(); - private volatile boolean cacheSizesReduced; - public GCInspector() { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); @@ -125,24 +122,7 @@ public class GCInspector // if we just finished a full collection and we're still using a lot of memory, try to reduce the pressure if (gc.getName().equals("ConcurrentMarkSweep")) - { SSTableDeletingTask.rescheduleFailedTasks(); - - double usage = (double) memoryUsed / memoryMax; - - if (memoryUsed > DatabaseDescriptor.getReduceCacheSizesAt() * memoryMax && !cacheSizesReduced) - { - cacheSizesReduced = true; - logger.warn("Heap is " + usage + " full. You may need to reduce memtable and/or cache sizes. Cassandra is now reducing cache sizes to free up memory. Adjust reduce_cache_sizes_at threshold in cassandra.yaml if you don't want Cassandra to do this automatically"); - CacheService.instance.reduceCacheSizes(); - } - - if (memoryUsed > DatabaseDescriptor.getFlushLargestMemtablesAt() * memoryMax) - { - logger.warn("Heap is " + usage + " full. You may need to reduce memtable and/or cache sizes. Cassandra will now flush up to the two largest memtables to free up memory. Adjust flush_largest_memtables_at threshold in cassandra.yaml if you don't want Cassandra to do this automatically"); - StorageService.instance.flushLargestMemtables(); - } - } } } } diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index 77b3c4a30a..9101a4c930 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -3516,32 +3516,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE ((DynamicEndpointSnitch)oldSnitch).unregisterMBean(); } - /** - * Flushes the two largest memtables by ops and by throughput - */ - public void flushLargestMemtables() - { - ColumnFamilyStore largest = null; - for (ColumnFamilyStore cfs : ColumnFamilyStore.all()) - { - long total = cfs.getTotalMemtableLiveSize(); - - if (total > 0 && (largest == null || total > largest.getTotalMemtableLiveSize())) - { - logger.debug(total + " estimated memtable size for " + cfs); - largest = cfs; - } - } - if (largest == null) - { - logger.info("Unable to reduce heap usage since there are no dirty column families"); - return; - } - - logger.warn("Flushing " + largest + " to relieve memory pressure"); - largest.forceFlush(); - } - /** * Seed data to the endpoints that will be responsible for it at the future * diff --git a/test/conf/cassandra.yaml b/test/conf/cassandra.yaml index 133e033029..a207bc6c4e 100644 --- a/test/conf/cassandra.yaml +++ b/test/conf/cassandra.yaml @@ -31,5 +31,4 @@ server_encryption_options: truststore: conf/.truststore truststore_password: cassandra incremental_backups: true -flush_largest_memtables_at: 1.0 compaction_throughput_mb_per_sec: 0 diff --git a/test/unit/org/apache/cassandra/db/RowCacheTest.java b/test/unit/org/apache/cassandra/db/RowCacheTest.java index c75cbc73a9..3dfef4d903 100644 --- a/test/unit/org/apache/cassandra/db/RowCacheTest.java +++ b/test/unit/org/apache/cassandra/db/RowCacheTest.java @@ -114,7 +114,7 @@ public class RowCacheTest extends SchemaLoader public void testRowCacheLoad() throws Exception { CacheService.instance.setRowCacheCapacityInMB(1); - rowCacheLoad(100, Integer.MAX_VALUE, false); + rowCacheLoad(100, Integer.MAX_VALUE); CacheService.instance.setRowCacheCapacityInMB(0); } @@ -122,11 +122,11 @@ public class RowCacheTest extends SchemaLoader public void testRowCachePartialLoad() throws Exception { CacheService.instance.setRowCacheCapacityInMB(1); - rowCacheLoad(100, 50, true); + rowCacheLoad(100, 50); CacheService.instance.setRowCacheCapacityInMB(0); } - public void rowCacheLoad(int totalKeys, int keysToSave, boolean reduceLoadCapacity) throws Exception + public void rowCacheLoad(int totalKeys, int keysToSave) throws Exception { CompactionManager.instance.disableAutoCompaction(); @@ -144,9 +144,6 @@ public class RowCacheTest extends SchemaLoader // force the cache to disk CacheService.instance.rowCache.submitWrite(keysToSave).get(); - if (reduceLoadCapacity) - CacheService.instance.reduceRowCacheSize(); - // empty the cache again to make sure values came from disk CacheService.instance.invalidateRowCache(); assert CacheService.instance.rowCache.size() == 0;