cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1104305 - in /cassandra/branches/cassandra-0.7: CHANGES.txt src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java
Date Tue, 17 May 2011 14:53:26 GMT
Author: jbellis
Date: Tue May 17 14:53:26 2011
New Revision: 1104305

URL: http://svn.apache.org/viewvc?rev=1104305&view=rev
Log:
mark BRAF buffer invalid post-flush so we don't re-flush partial buffers again
patch by Peter Schuller; reviewed by jbellis for CASSANDRA-2660

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1104305&r1=1104304&r2=1104305&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Tue May 17 14:53:26 2011
@@ -1,6 +1,8 @@
 0.7.7
  * adjust hinted handoff page size to avoid OOM with large columns 
    (CASSANDRA-2652)
+ * mark BRAF buffer invalid post-flush so we don't re-flush partial
+   buffers again, especially on CL writes (CASSANDRA-2660)
 
 
 0.7.6

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java?rev=1104305&r1=1104304&r2=1104305&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java
Tue May 17 14:53:26 2011
@@ -128,6 +128,9 @@ public class BufferedRandomAccessFile ex
         fd = CLibrary.getfd(this.getFD());
     }
 
+    /**
+     * Flush (flush()) whatever writes are pending, and block until the data has been persistently
committed (fsync()).
+     */
     public void sync() throws IOException
     {
         if (syncNeeded)
@@ -150,6 +153,11 @@ public class BufferedRandomAccessFile ex
         }
     }
 
+    /**
+     * If we are dirty, flush dirty contents to the operating system. Does not imply fsync().
+     *
+     * Currently, for implementation reasons, this also invalidates the buffer.
+     */
     public void flush() throws IOException
     {
         if (isDirty)
@@ -181,20 +189,25 @@ public class BufferedRandomAccessFile ex
 
             }
 
+            // Remember that we wrote, so we don't write it again on next flush().
+            resetBuffer();
+
             isDirty = false;
         }
     }
 
+    private void resetBuffer()
+    {
+        bufferOffset = current;
+        validBufferBytes = 0;
+    }
+
     private void reBuffer() throws IOException
     {
         flush(); // synchronizing buffer and file on disk
-
-        bufferOffset = current;
+        resetBuffer();
         if (bufferOffset >= channel.size())
-        {
-            validBufferBytes = 0;
             return;
-        }
 
         if (bufferOffset < minBufferOffset)
             minBufferOffset = bufferOffset;



Mime
View raw message