Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 6db2a2e8a -> 6214e3540
  refs/heads/cassandra-2.1 52d19e20f -> 9d421f354
  refs/heads/trunk e88733690 -> 4b16c1116


Ensure SSTableSimpleUnsortedWriter.close() terminates if
disk writer has crashed

patch by benedict; reviewed by josh for CASSANDRA-8807


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/6214e354
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/6214e354
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/6214e354

Branch: refs/heads/cassandra-2.0
Commit: 6214e35401777ac3068a2344c345b425159375c0
Parents: 6db2a2e
Author: Benedict Elliott Smith <[email protected]>
Authored: Thu Feb 19 11:56:48 2015 +0000
Committer: Benedict Elliott Smith <[email protected]>
Committed: Thu Feb 19 11:56:48 2015 +0000

----------------------------------------------------------------------
 CHANGES.txt                                     |  3 ++-
 .../io/sstable/SSTableSimpleUnsortedWriter.java | 21 ++++++++++----------
 2 files changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6214e354/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f68c987..09d6d2f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -19,7 +19,8 @@
  * Add batch remove iterator to ABSC (CASSANDRA-8414, 8666)
  * Fix isClientMode check in Keyspace (CASSANDRA-8687)
  * 'nodetool info' prints exception against older node (CASSANDRA-8796)
-
+ * Ensure SSTableSimpleUnsortedWriter.close() terminates if
+   disk writer has crashed (CASSANDRA-8807)
 
 2.0.12:
  * Use more efficient slice size for querying internal secondary

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6214e354/src/java/org/apache/cassandra/io/sstable/SSTableSimpleUnsortedWriter.java
----------------------------------------------------------------------
diff --git 
a/src/java/org/apache/cassandra/io/sstable/SSTableSimpleUnsortedWriter.java 
b/src/java/org/apache/cassandra/io/sstable/SSTableSimpleUnsortedWriter.java
index 614ca7d..5bddea3 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableSimpleUnsortedWriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableSimpleUnsortedWriter.java
@@ -148,17 +148,15 @@ public class SSTableSimpleUnsortedWriter extends 
AbstractSSTableSimpleWriter
     public void close() throws IOException
     {
         sync();
+        put(SENTINEL);
         try
         {
-            writeQueue.put(SENTINEL);
             diskWriter.join();
         }
         catch (InterruptedException e)
         {
             throw new RuntimeException(e);
         }
-
-        checkForWriterException();
     }
 
     private void sync() throws IOException
@@ -166,25 +164,28 @@ public class SSTableSimpleUnsortedWriter extends 
AbstractSSTableSimpleWriter
         if (buffer.isEmpty())
             return;
 
+        columnFamily = null;
+        put(buffer);
+        buffer = new Buffer();
+        currentSize = 0;
+        columnFamily = getColumnFamily();
+    }
+
+    private void put(Buffer buffer) throws IOException
+    {
         while (true)
         {
             checkForWriterException();
-
-            columnFamily = null;
             try
             {
-                if (writeQueue.offer(buffer, 1L, TimeUnit.SECONDS))
+                if (writeQueue.offer(buffer, 1, TimeUnit.SECONDS))
                     break;
             }
             catch (InterruptedException e)
             {
                 throw new RuntimeException(e);
-
             }
         }
-        buffer = new Buffer();
-        currentSize = 0;
-        columnFamily = getColumnFamily();
     }
 
     private void checkForWriterException() throws IOException

Reply via email to