You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by be...@apache.org on 2015/06/03 14:10:17 UTC
[2/9] cassandra git commit: Ensure truncate without snapshot cannot
return corrupt responses
Ensure truncate without snapshot cannot return corrupt responses
patch by benedict; reviewed by aleksey for CASSANDRA-9388
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/62500650
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/62500650
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/62500650
Branch: refs/heads/trunk
Commit: 6250065089b80d02d54908212d2b5f45037720f2
Parents: 40c3ad6
Author: Benedict Elliott Smith <be...@apache.org>
Authored: Tue Jun 2 18:11:45 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Tue Jun 2 18:11:45 2015 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../apache/cassandra/db/ColumnFamilyStore.java | 32 +++++++++++---------
2 files changed, 19 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/62500650/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 75eb752..9ce5680 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.1.6
+ * Ensure truncate without snapshot cannot produce corrupt responses (CASSANDRA-9388)
* Consistent error message when a table mixes counter and non-counter
columns (CASSANDRA-9492)
* Avoid getting unreadable keys during anticompaction (CASSANDRA-9508)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/62500650/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 5f47476..d686e67 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1078,7 +1078,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
if (memtable.isClean() || truncate)
{
memtable.cfs.replaceFlushed(memtable, null);
- memtable.setDiscarded();
+ reclaim(memtable);
iter.remove();
}
}
@@ -1091,27 +1091,31 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
metric.memtableSwitchCount.inc();
- for (final Memtable memtable : memtables)
+ for (Memtable memtable : memtables)
{
// flush the memtable
MoreExecutors.sameThreadExecutor().execute(memtable.flushRunnable());
-
- // issue a read barrier for reclaiming the memory, and offload the wait to another thread
- final OpOrder.Barrier readBarrier = readOrdering.newBarrier();
- readBarrier.issue();
- reclaimExecutor.execute(new WrappedRunnable()
- {
- public void runMayThrow() throws InterruptedException, ExecutionException
- {
- readBarrier.await();
- memtable.setDiscarded();
- }
- });
+ reclaim(memtable);
}
// signal the post-flush we've done our work
postFlush.latch.countDown();
}
+
+ private void reclaim(final Memtable memtable)
+ {
+ // issue a read barrier for reclaiming the memory, and offload the wait to another thread
+ final OpOrder.Barrier readBarrier = readOrdering.newBarrier();
+ readBarrier.issue();
+ reclaimExecutor.execute(new WrappedRunnable()
+ {
+ public void runMayThrow() throws InterruptedException, ExecutionException
+ {
+ readBarrier.await();
+ memtable.setDiscarded();
+ }
+ });
+ }
}
/**