From f0c7a6f03cf55ddcfe11a58c80087ed8b0806cf4 Mon Sep 17 00:00:00 2001 From: Benedict Elliott Smith Date: Fri, 1 May 2015 11:32:31 +0100 Subject: [PATCH] Fix partition-level-delete-only workload accounting patch by benedict; reviewed by jbellis for CASSANDRA-9194 --- CHANGES.txt | 1 + src/java/org/apache/cassandra/db/Memtable.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 4e7a5d0267..dfdad516f8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.0.15: + * Fix partition-level-delete-only workload accounting (CASSANDRA-9194) * Allow scrub to handle corrupted compressed chunks (CASSANDRA-9140) * Fix assertion error when resetlocalschema is run during repair (CASSANDRA-9249) * Disable single sstable tombstone compactions for DTCS by default (CASSANDRA-9234) diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java index 19f38be638..897d94ed0b 100644 --- a/src/java/org/apache/cassandra/db/Memtable.java +++ b/src/java/org/apache/cassandra/db/Memtable.java @@ -206,17 +206,21 @@ public class Memtable { AtomicSortedColumns previous = rows.get(key); + long initialSize = 0; if (previous == null) { AtomicSortedColumns empty = cf.cloneMeShallow(AtomicSortedColumns.factory, false); // We'll add the columns later. This avoids wasting works if we get beaten in the putIfAbsent previous = rows.putIfAbsent(new DecoratedKey(key.token, allocator.clone(key.key)), empty); if (previous == null) + { previous = empty; + initialSize += 1; + } } final Pair pair = previous.addAllWithSizeDelta(cf, allocator, localCopyFunction, indexer); - currentSize.addAndGet(pair.left); + currentSize.addAndGet(initialSize + pair.left); currentOperations.addAndGet(cf.getColumnCount() + (cf.isMarkedForDelete() ? 1 : 0) + cf.deletionInfo().rangeCount()); return pair.right; }