You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by to...@apache.org on 2011/10/17 19:36:49 UTC

svn commit: r1185300 - in /hbase/branches/0.92: CHANGES.txt src/main/java/org/apache/hadoop/hbase/KeyValue.java

Author: todd
Date: Mon Oct 17 17:36:49 2011
New Revision: 1185300

URL: http://svn.apache.org/viewvc?rev=1185300&view=rev
Log:
HBASE-4570. Fix a race condition that could cause inconsistent results from scans during concurrent writes.

Modified:
    hbase/branches/0.92/CHANGES.txt
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/KeyValue.java

Modified: hbase/branches/0.92/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1185300&r1=1185299&r2=1185300&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Mon Oct 17 17:36:49 2011
@@ -707,6 +707,9 @@ Release 0.90.5 - Unreleased
                deferred flush edits
    HBASE-4563  When error occurs in this.parent.close(false) of split,
                the split region cannot write or read (bluedavy via Lars H)
+   HBASE-4570. Fix a race condition that could cause inconsistent results
+               from scans during concurrent writes. (todd and Jonathan Jsieh
+               via todd)
 
   IMPROVEMENT
    HBASE-4205  Enhance HTable javadoc (Eric Charles)

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/KeyValue.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/KeyValue.java?rev=1185300&r1=1185299&r2=1185300&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/KeyValue.java (original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/KeyValue.java Mon Oct 17 17:36:49 2011
@@ -205,7 +205,7 @@ public class KeyValue implements Writabl
   private int length = 0;
 
   // the row cached
-  private byte [] rowCache = null;
+  private volatile byte [] rowCache = null;
 
 
   /** Here be dragons **/
@@ -911,8 +911,11 @@ public class KeyValue implements Writabl
     if (rowCache == null) {
       int o = getRowOffset();
       short l = getRowLength();
-      rowCache = new byte[l];
-      System.arraycopy(getBuffer(), o, rowCache, 0, l);
+      // initialize and copy the data into a local variable
+      // in case multiple threads race here.
+      byte local[] = new byte[l];
+      System.arraycopy(getBuffer(), o, local, 0, l);
+      rowCache = local; // volatile assign
     }
     return rowCache;
   }