diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 5a1e47da37..3f92e9d035 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1004,11 +1004,6 @@ public final class ColumnFamilyStore implements ColumnFamilyStoreMBean
return isSuper_;
}
- public void flushMemtableOnRecovery() throws IOException
- {
- getMemtableThreadSafe().flushOnRecovery();
- }
-
public int getMemtableColumnsCount()
{
return getMemtableThreadSafe().getCurrentObjectCount();
diff --git a/src/java/org/apache/cassandra/db/CommitLog.java b/src/java/org/apache/cassandra/db/CommitLog.java
index 8c72cf90da..7b7d7d24e7 100644
--- a/src/java/org/apache/cassandra/db/CommitLog.java
+++ b/src/java/org/apache/cassandra/db/CommitLog.java
@@ -32,6 +32,7 @@ import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -283,8 +284,9 @@ public class CommitLog
void recover(File[] clogs) throws IOException
{
- DataInputBuffer bufIn = new DataInputBuffer();
+ Set
tablesRecovered = new HashSet();
+ DataInputBuffer bufIn = new DataInputBuffer();
for (File file : clogs)
{
int bufferSize = (int)Math.min(file.length(), 32 * 1024 * 1024);
@@ -299,8 +301,6 @@ public class CommitLog
if (logger_.isDebugEnabled())
logger_.debug("Replaying " + file + " starting at " + lowPos);
- Set tablesRecovered = new HashSet();
-
/* read the logs populate RowMutation and apply */
while (!reader.isEOF())
{
@@ -348,10 +348,24 @@ public class CommitLog
}
}
reader.close();
- /* apply the rows read -- success will result in the CL file being discarded */
- for (Table table : tablesRecovered)
+ }
+
+ // flush replayed tables, allowing commitlog segments to be removed
+ List> futures = new ArrayList>();
+ for (Table table : tablesRecovered)
+ {
+ futures.addAll(table.flush());
+ }
+ // wait for flushes to finish before continuing with startup
+ for (Future> future : futures)
+ {
+ try
{
- table.flush(true);
+ future.get();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
}
}
}
diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java
index 5ce02f0a2f..d61e2845dc 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -166,15 +166,6 @@ public class Memtable implements Comparable, IFlushable
}
}
- /** flush synchronously (in the current thread, not on the executors).
- * only the recover code should call this. */
- void flushOnRecovery() throws IOException {
- if (!isClean())
- {
- writeSortedContents(getSortedKeys());
- }
- }
-
// for debugging
public String contents()
{
diff --git a/src/java/org/apache/cassandra/db/Table.java b/src/java/org/apache/cassandra/db/Table.java
index 6ac5948e97..eb8424e69e 100644
--- a/src/java/org/apache/cassandra/db/Table.java
+++ b/src/java/org/apache/cassandra/db/Table.java
@@ -24,6 +24,7 @@ import java.io.File;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.concurrent.Future;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.dht.Range;
@@ -487,19 +488,16 @@ public class Table
}
}
- public void flush(boolean fRecovery) throws IOException
+ public List> flush() throws IOException
{
+ List> futures = new ArrayList>();
for (String cfName : columnFamilyStores_.keySet())
{
- if (fRecovery)
- {
- columnFamilyStores_.get(cfName).flushMemtableOnRecovery();
- }
- else
- {
- columnFamilyStores_.get(cfName).forceFlush();
- }
+ Future> future = columnFamilyStores_.get(cfName).forceFlush();
+ if (future != null)
+ futures.add(future);
}
+ return futures;
}
// for binary load path. skips commitlog.
diff --git a/src/java/org/apache/cassandra/io/Streaming.java b/src/java/org/apache/cassandra/io/Streaming.java
index a9e4793b42..3e16569072 100644
--- a/src/java/org/apache/cassandra/io/Streaming.java
+++ b/src/java/org/apache/cassandra/io/Streaming.java
@@ -52,7 +52,7 @@ public class Streaming
Table table = Table.open(tName);
if (logger.isDebugEnabled())
logger.debug("Flushing memtables ...");
- table.flush(false);
+ table.flush();
if (logger.isDebugEnabled())
logger.debug("Performing anticompaction ...");
/* Get the list of files that need to be streamed */