Improve config validation and documentation on overflow and NPE

patch by Zhao Yang; reviewed by Kurt Greaves for CASSANDRA-13622
This commit is contained in:
Zhao Yang 2017-09-12 14:31:07 +01:00 committed by Andrés de la Peña
parent 12103653f3
commit a586f6c88d
4 changed files with 24 additions and 4 deletions

View File

@ -1,5 +1,6 @@
3.0.15
* Fix pending view mutations handling and cleanup batchlog when there are local and remote paired mutations (CASSANDRA-13069)
* Improve config validation and documentation on overflow and NPE (CASSANDRA-13622)
* Range deletes in a CAS batch are ignored (CASSANDRA-13655)
* Change repair midpoint logging for tiny ranges (CASSANDRA-13603)
* Better handle corrupt final commitlog segment (CASSANDRA-11995)

View File

@ -315,6 +315,7 @@ commitlog_sync_period_in_ms: 10000
# is reasonable.
# Max mutation size is also configurable via max_mutation_size_in_kb setting in
# cassandra.yaml. The default is half the size commitlog_segment_size_in_mb * 1024.
# This should be positive and less than 2048.
#
# NOTE: If max_mutation_size_in_kb is set explicitly then commitlog_segment_size_in_mb must
# be set to at least twice the size of max_mutation_size_in_kb / 1024
@ -517,7 +518,7 @@ native_transport_port: 9042
#
# The maximum size of allowed frame. Frame (requests) larger than this will
# be rejected as invalid. The default is 256MB. If you're changing this parameter,
# you may want to adjust max_value_size_in_mb accordingly.
# you may want to adjust max_value_size_in_mb accordingly. This should be positive and less than 2048.
# native_transport_max_frame_size_in_mb: 256
# The maximum number of concurrent client connections.
@ -960,7 +961,7 @@ windows_timer_interval: 1
# Maximum size of any value in SSTables. Safety measure to detect SSTable corruption
# early. Any value size larger than this threshold will result into marking an SSTable
# as corrupted.
# as corrupted. This should be positive and less than 2048.
# max_value_size_in_mb: 256
# Coalescing Strategies #

View File

@ -442,6 +442,9 @@ public class DatabaseDescriptor
if (conf.native_transport_max_frame_size_in_mb <= 0)
throw new ConfigurationException("native_transport_max_frame_size_in_mb must be positive, but was " + conf.native_transport_max_frame_size_in_mb, false);
else if (conf.native_transport_max_frame_size_in_mb >= 2048)
throw new ConfigurationException("native_transport_max_frame_size_in_mb must be smaller than 2048, but was "
+ conf.native_transport_max_frame_size_in_mb, false);
// fail early instead of OOMing (see CASSANDRA-8116)
if (ThriftServer.HSHA.equals(conf.rpc_server_type) && conf.rpc_max_threads == Integer.MAX_VALUE)
@ -576,6 +579,8 @@ public class DatabaseDescriptor
/* data file and commit log directories. they get created later, when they're needed. */
for (String datadir : conf.data_file_directories)
{
if (datadir == null)
throw new ConfigurationException("data_file_directories must not contain empty entry", false);
if (datadir.equals(conf.commitlog_directory))
throw new ConfigurationException("commitlog_directory must not be the same as any data_file_directories", false);
if (datadir.equals(conf.hints_directory))
@ -718,6 +723,13 @@ public class DatabaseDescriptor
if (conf.user_defined_function_fail_timeout < conf.user_defined_function_warn_timeout)
throw new ConfigurationException("user_defined_function_warn_timeout must less than user_defined_function_fail_timeout", false);
if (conf.commitlog_segment_size_in_mb <= 0)
throw new ConfigurationException("commitlog_segment_size_in_mb must be positive, but was "
+ conf.commitlog_segment_size_in_mb, false);
else if (conf.commitlog_segment_size_in_mb >= 2048)
throw new ConfigurationException("commitlog_segment_size_in_mb must be smaller than 2048, but was "
+ conf.commitlog_segment_size_in_mb, false);
if (conf.max_mutation_size_in_kb == null)
conf.max_mutation_size_in_kb = conf.commitlog_segment_size_in_mb * 1024 / 2;
else if (conf.commitlog_segment_size_in_mb * 1024 < 2 * conf.max_mutation_size_in_kb)
@ -733,6 +745,9 @@ public class DatabaseDescriptor
if (conf.max_value_size_in_mb == null || conf.max_value_size_in_mb <= 0)
throw new ConfigurationException("max_value_size_in_mb must be positive", false);
else if (conf.max_value_size_in_mb >= 2048)
throw new ConfigurationException("max_value_size_in_mb must be smaller than 2048, but was "
+ conf.max_value_size_in_mb, false);
if (conf.otc_coalescing_enough_coalesced_messages > 128)
throw new ConfigurationException("otc_coalescing_enough_coalesced_messages must be smaller than 128", false);

View File

@ -34,6 +34,8 @@ import javax.annotation.Nullable;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -82,8 +84,9 @@ public class FBUtilities
public static int getAvailableProcessors()
{
if (System.getProperty("cassandra.available_processors") != null)
return Integer.parseInt(System.getProperty("cassandra.available_processors"));
String availableProcessors = System.getProperty("cassandra.available_processors");
if (!Strings.isNullOrEmpty(availableProcessors))
return Integer.parseInt(availableProcessors);
else
return Runtime.getRuntime().availableProcessors();
}