Record CAS contention for write timeouts in prepare phase

Patch by Christopher Batey; Reviewed by Edward Capriolo for CASSANDRA-12626
This commit is contained in:
Christopher Batey 2016-09-10 18:35:37 +01:00 committed by Jeff Jirsa
parent 747a62f607
commit 3bf043e4e4
2 changed files with 10 additions and 2 deletions

View File

@ -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)

View File

@ -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<InetAddress> 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)));
}