Ensure truncate without snapshot cannot return corrupt responses

patch by benedict; reviewed by aleksey for CASSANDRA-9388
This commit is contained in:
Benedict Elliott Smith 2015-06-02 18:11:45 +01:00
parent 4bf8076872
commit b9a89a3acc
2 changed files with 19 additions and 14 deletions

View File

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

View File

@ -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();
}
});
}
}
/**