From 3bf043e4e4790b0d6ef5cfe12ff80f813945a302 Mon Sep 17 00:00:00 2001 From: Christopher Batey Date: Sat, 10 Sep 2016 18:35:37 +0100 Subject: [PATCH] Record CAS contention for write timeouts in prepare phase Patch by Christopher Batey; Reviewed by Edward Capriolo for CASSANDRA-12626 --- CHANGES.txt | 1 + .../org/apache/cassandra/service/StorageProxy.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index a5b0addb0f..dc98ca7a72 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -84,6 +84,7 @@ * Remove pre-startup check for open JMX port (CASSANDRA-12074) * Remove compaction Severity from DynamicEndpointSnitch (CASSANDRA-11738) * Restore resumable hints delivery (CASSANDRA-11960) + * Properly report LWT contention (CASSANDRA-12626) Merged from 3.0: * Improve avg aggregate functions (CASSANDRA-12417) * Preserve quoted reserved keyword column names in MV creation (CASSANDRA-11803) diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java index 5ad19e0d61..529e4e3539 100644 --- a/src/java/org/apache/cassandra/service/StorageProxy.java +++ b/src/java/org/apache/cassandra/service/StorageProxy.java @@ -321,14 +321,19 @@ public class StorageProxy implements StorageProxyMBean } finally { - if(contentions > 0) - casWriteMetrics.contention.update(contentions); + recordCasContention(contentions); final long latency = System.nanoTime() - startTimeForMetrics; casWriteMetrics.addNano(latency); writeMetricsMap.get(consistencyForPaxos).addNano(latency); } } + private static void recordCasContention(int contentions) + { + if(contentions > 0) + casWriteMetrics.contention.update(contentions); + } + private static Predicate sameDCPredicateFor(final String dc) { final IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch(); @@ -439,6 +444,7 @@ public class StorageProxy implements StorageProxyMBean } catch (WriteTimeoutException e) { + recordCasContention(contentions); // We're still doing preparation for the paxos rounds, so we want to use the CAS (see CASSANDRA-8672) throw new WriteTimeoutException(WriteType.CAS, e.consistency, e.received, e.blockFor); } @@ -473,6 +479,7 @@ public class StorageProxy implements StorageProxyMBean return Pair.create(ballot, contentions); } + recordCasContention(contentions); throw new WriteTimeoutException(WriteType.CAS, consistencyForPaxos, 0, consistencyForPaxos.blockFor(Keyspace.open(metadata.ksName))); }