diff --git a/CHANGES.txt b/CHANGES.txt index c7fccce46b..2dcbb6982b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -44,6 +44,7 @@ * Add the ability to disable bulk loading of SSTables (CASSANDRA-18781) * Clean up obsolete functions and simplify cql_version handling in cqlsh (CASSANDRA-18787) Merged from 5.0: + * Replace Stream iteration with for-loop for StorageProxy::updateCoordinatorWriteLatencyTableMetric (CASSANDRA-19676) * Enforce metric naming contract if scope is used in a metric name (CASSANDRA-19619) * Avoid reading of the same IndexInfo from disk many times for a large partition (CASSANDRA-19557) * Resolve the oldest hints just from descriptors and current writer if available (CASSANDRA-19600) diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java index 2c26d36d6d..e66fe6546e 100644 --- a/src/java/org/apache/cassandra/service/StorageProxy.java +++ b/src/java/org/apache/cassandra/service/StorageProxy.java @@ -1273,10 +1273,16 @@ public class StorageProxy implements StorageProxyMBean { //We could potentially pass a callback into performWrite. And add callback provision for mutateCounter or mutateAtomically (sendToHintedEndPoints) //However, Trade off between write metric per CF accuracy vs performance hit due to callbacks. Similar issue exists with CoordinatorReadLatency metric. - mutations.stream() - .flatMap(m -> m.getTableIds().stream().map(tableId -> Keyspace.open(m.getKeyspaceName()).getColumnFamilyStore(tableId))) - .distinct() - .forEach(store -> store.metric.coordinatorWriteLatency.update(latency, TimeUnit.NANOSECONDS)); + Set uniqueColumnFamilyStores = new HashSet<>(); + for (IMutation mutation : mutations) + { + for (TableId tableId : mutation.getTableIds()) + { + ColumnFamilyStore store = Keyspace.open(mutation.getKeyspaceName()).getColumnFamilyStore(tableId); + if (uniqueColumnFamilyStores.add(store)) + store.metric.coordinatorWriteLatency.update(latency, NANOSECONDS); + } + } } catch (Exception ex) {