mirror of https://github.com/apache/cassandra
use explicit dirty flag instead of trying to cheat and use executor taskcount, which is race-prone. patch by jbellis; reviewed by Eric Evans for CASSANDRA-134
git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@772680 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4a2ba89fe3
commit
3395efdb30
|
|
@ -57,6 +57,7 @@ public class Memtable implements Comparable<Memtable>
|
|||
|
||||
private MemtableThreadPoolExecutor executor_;
|
||||
private volatile boolean isFrozen_;
|
||||
private volatile boolean isDirty_;
|
||||
private volatile boolean isFlushed_; // for tests, in particular forceBlockingFlush asserts this
|
||||
|
||||
private int threshold_ = DatabaseDescriptor.getMemtableSize()*1024*1024;
|
||||
|
|
@ -195,6 +196,7 @@ public class Memtable implements Comparable<Memtable>
|
|||
*/
|
||||
void put(String key, ColumnFamily columnFamily, CommitLog.CommitLogContext cLogCtx) throws IOException
|
||||
{
|
||||
isDirty_ = true;
|
||||
executor_.submit(new Putter(key, columnFamily));
|
||||
if (isThresholdViolated())
|
||||
{
|
||||
|
|
@ -411,6 +413,8 @@ public class Memtable implements Comparable<Memtable>
|
|||
|
||||
public boolean isClean()
|
||||
{
|
||||
return columnFamilies_.isEmpty() && executor_.getPendingTasks() == 0;
|
||||
// executor taskcount is inadequate for our needs here -- it can return zero under certain
|
||||
// race conditions even though a task has been processed.
|
||||
return !isDirty_;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue