You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ja...@apache.org on 2017/08/23 22:09:05 UTC
cassandra git commit: force minumum timeout value
Repository: cassandra
Updated Branches:
refs/heads/trunk fc92db2b9 -> d2dcd7f88
force minumum timeout value
patch by Varun Barala; reviewed by jasobrown for CASSANDRA-9375
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/d2dcd7f8
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/d2dcd7f8
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/d2dcd7f8
Branch: refs/heads/trunk
Commit: d2dcd7f884cc997905c820d7cef8c9fc886ff4f7
Parents: fc92db2
Author: Jason Brown <ja...@gmail.com>
Authored: Wed Aug 23 15:08:11 2017 -0700
Committer: Jason Brown <ja...@gmail.com>
Committed: Wed Aug 23 15:08:11 2017 -0700
----------------------------------------------------------------------
CHANGES.txt | 1 +
NEWS.txt | 3 +
conf/cassandra.yaml | 19 +++++--
.../cassandra/config/DatabaseDescriptor.java | 58 ++++++++++++++++++++
.../config/DatabaseDescriptorTest.java | 40 ++++++++++++++
5 files changed, 115 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/d2dcd7f8/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a14e390..d0ec78d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
4.0
+ * force minumum timeout value (CASSANDRA-9375)
* use netty for streaming (CASSANDRA-12229)
* Use netty for internode messaging (CASSANDRA-8457)
* Add bytes repaired/unrepaired to nodetool tablestats (CASSANDRA-13774)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/d2dcd7f8/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index 4d30631..253d773 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -60,6 +60,9 @@ Upgrading
- Config option index_interval has been removed (it was deprecated since 2.0)
- Deprecated repair JMX APIs are removed.
- The version of snappy-java has been upgraded to 1.1.2.6
+ - the miniumum value for internode message timeouts is 10ms. Previously, any
+ positive value was allowed. See cassandra.yaml entries like
+ read_request_timeout_in_ms for more details.
3.11.0
======
http://git-wip-us.apache.org/repos/asf/cassandra/blob/d2dcd7f8/conf/cassandra.yaml
----------------------------------------------------------------------
diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml
index bdc68d1..3db82a1 100644
--- a/conf/cassandra.yaml
+++ b/conf/cassandra.yaml
@@ -780,22 +780,29 @@ sstable_preemptive_open_interval_in_mb: 50
# When unset, the default is 200 Mbps or 25 MB/s
# inter_dc_stream_throughput_outbound_megabits_per_sec: 200
-# How long the coordinator should wait for read operations to complete
+# How long the coordinator should wait for read operations to complete.
+# Lowest acceptable value is 10 ms.
read_request_timeout_in_ms: 5000
-# How long the coordinator should wait for seq or index scans to complete
+# How long the coordinator should wait for seq or index scans to complete.
+# Lowest acceptable value is 10 ms.
range_request_timeout_in_ms: 10000
-# How long the coordinator should wait for writes to complete
+# How long the coordinator should wait for writes to complete.
+# Lowest acceptable value is 10 ms.
write_request_timeout_in_ms: 2000
-# How long the coordinator should wait for counter writes to complete
+# How long the coordinator should wait for counter writes to complete.
+# Lowest acceptable value is 10 ms.
counter_write_request_timeout_in_ms: 5000
# How long a coordinator should continue to retry a CAS operation
-# that contends with other proposals for the same row
+# that contends with other proposals for the same row.
+# Lowest acceptable value is 10 ms.
cas_contention_timeout_in_ms: 1000
# How long the coordinator should wait for truncates to complete
# (This can be much longer, because unless auto_snapshot is disabled
# we need to flush first so we can snapshot before removing the data.)
+# Lowest acceptable value is 10 ms.
truncate_request_timeout_in_ms: 60000
-# The default timeout for other, miscellaneous operations
+# The default timeout for other, miscellaneous operations.
+# Lowest acceptable value is 10 ms.
request_timeout_in_ms: 10000
# How long before a node logs slow queries. Select queries that take longer than
http://git-wip-us.apache.org/repos/asf/cassandra/blob/d2dcd7f8/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index 302a528..a839224 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -77,6 +77,11 @@ public class DatabaseDescriptor
private static Config conf;
+ /**
+ * Request timeouts can not be less than below defined value (see CASSANDRA-9375)
+ */
+ static final long LOWEST_ACCEPTED_TIMEOUT = 10L;
+
private static IEndpointSnitch snitch;
private static InetAddress listenAddress; // leave null so we can fall through to getLocalHost
private static InetAddress broadcastAddress;
@@ -414,6 +419,8 @@ public class DatabaseDescriptor
else
logger.info("Global memtable off-heap threshold is enabled at {}MB", conf.memtable_offheap_space_in_mb);
+ checkForLowestAcceptedTimeouts(conf);
+
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);
@@ -838,6 +845,57 @@ public class DatabaseDescriptor
throw new ConfigurationException("The seed provider lists no seeds.", false);
}
+ @VisibleForTesting
+ static void checkForLowestAcceptedTimeouts(Config conf)
+ {
+ if(conf.read_request_timeout_in_ms < LOWEST_ACCEPTED_TIMEOUT)
+ {
+ logInfo("read_request_timeout_in_ms", conf.read_request_timeout_in_ms, LOWEST_ACCEPTED_TIMEOUT);
+ conf.read_request_timeout_in_ms = LOWEST_ACCEPTED_TIMEOUT;
+ }
+
+ if(conf.range_request_timeout_in_ms < LOWEST_ACCEPTED_TIMEOUT)
+ {
+ logInfo("range_request_timeout_in_ms", conf.range_request_timeout_in_ms, LOWEST_ACCEPTED_TIMEOUT);
+ conf.range_request_timeout_in_ms = LOWEST_ACCEPTED_TIMEOUT;
+ }
+
+ if(conf.request_timeout_in_ms < LOWEST_ACCEPTED_TIMEOUT)
+ {
+ logInfo("request_timeout_in_ms", conf.request_timeout_in_ms, LOWEST_ACCEPTED_TIMEOUT);
+ conf.request_timeout_in_ms = LOWEST_ACCEPTED_TIMEOUT;
+ }
+
+ if(conf.write_request_timeout_in_ms < LOWEST_ACCEPTED_TIMEOUT)
+ {
+ logInfo("write_request_timeout_in_ms", conf.write_request_timeout_in_ms, LOWEST_ACCEPTED_TIMEOUT);
+ conf.write_request_timeout_in_ms = LOWEST_ACCEPTED_TIMEOUT;
+ }
+
+ if(conf.cas_contention_timeout_in_ms < LOWEST_ACCEPTED_TIMEOUT)
+ {
+ logInfo("cas_contention_timeout_in_ms", conf.cas_contention_timeout_in_ms, LOWEST_ACCEPTED_TIMEOUT);
+ conf.cas_contention_timeout_in_ms = LOWEST_ACCEPTED_TIMEOUT;
+ }
+
+ if(conf.counter_write_request_timeout_in_ms < LOWEST_ACCEPTED_TIMEOUT)
+ {
+ logInfo("counter_write_request_timeout_in_ms", conf.counter_cache_keys_to_save, LOWEST_ACCEPTED_TIMEOUT);
+ conf.counter_write_request_timeout_in_ms = LOWEST_ACCEPTED_TIMEOUT;
+ }
+
+ if(conf.truncate_request_timeout_in_ms < LOWEST_ACCEPTED_TIMEOUT)
+ {
+ logInfo("truncate_request_timeout_in_ms", conf.truncate_request_timeout_in_ms, LOWEST_ACCEPTED_TIMEOUT);
+ conf.truncate_request_timeout_in_ms = LOWEST_ACCEPTED_TIMEOUT;
+ }
+ }
+
+ private static void logInfo(String property, long actualValue, long lowestAcceptedValue)
+ {
+ logger.info("found {}::{} less than lowest acceptable value {}, continuing with {}", property, actualValue, lowestAcceptedValue, lowestAcceptedValue);
+ }
+
public static void applyInitialTokens()
{
if (conf.initial_token != null)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/d2dcd7f8/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
index c1dc268..3d88164 100644
--- a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
+++ b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
@@ -210,4 +210,44 @@ public class DatabaseDescriptorTest
assertEquals(7, tokens.size());
assertTrue(tokens.containsAll(Arrays.asList(new String[]{"a", "b", "c", "d", "f", "g", "h"})));
}
+
+ @Test
+ public void testLowestAcceptableTimeouts() throws ConfigurationException
+ {
+ Config testConfig = new Config();
+ testConfig.read_request_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT + 1;
+ testConfig.range_request_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT + 1;
+ testConfig.write_request_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT + 1;
+ testConfig.truncate_request_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT + 1;
+ testConfig.cas_contention_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT + 1;
+ testConfig.counter_write_request_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT + 1;
+ testConfig.request_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT + 1;
+
+ assertTrue(testConfig.read_request_timeout_in_ms > DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ assertTrue(testConfig.range_request_timeout_in_ms > DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ assertTrue(testConfig.write_request_timeout_in_ms > DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ assertTrue(testConfig.truncate_request_timeout_in_ms > DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ assertTrue(testConfig.cas_contention_timeout_in_ms > DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ assertTrue(testConfig.counter_write_request_timeout_in_ms > DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ assertTrue(testConfig.request_timeout_in_ms > DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+
+ //set less than Lowest acceptable value
+ testConfig.read_request_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT - 1;
+ testConfig.range_request_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT - 1;
+ testConfig.write_request_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT - 1;
+ testConfig.truncate_request_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT - 1;
+ testConfig.cas_contention_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT - 1;
+ testConfig.counter_write_request_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT - 1;
+ testConfig.request_timeout_in_ms = DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT - 1;
+
+ DatabaseDescriptor.checkForLowestAcceptedTimeouts(testConfig);
+
+ assertTrue(testConfig.read_request_timeout_in_ms == DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ assertTrue(testConfig.range_request_timeout_in_ms == DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ assertTrue(testConfig.write_request_timeout_in_ms == DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ assertTrue(testConfig.truncate_request_timeout_in_ms == DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ assertTrue(testConfig.cas_contention_timeout_in_ms == DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ assertTrue(testConfig.counter_write_request_timeout_in_ms == DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ assertTrue(testConfig.request_timeout_in_ms == DatabaseDescriptor.LOWEST_ACCEPTED_TIMEOUT);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org