hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1185301 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/KeyValue.java
Date Mon, 17 Oct 2011 17:37:04 GMT
Author: todd
Date: Mon Oct 17 17:37:03 2011
New Revision: 1185301

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

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

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1185301&r1=1185300&r2=1185301&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Mon Oct 17 17:37:03 2011
@@ -736,6 +736,9 @@ Release 0.90.5 - Unreleased
                sources running
    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/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java?rev=1185301&r1=1185300&r2=1185301&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/KeyValue.java Mon Oct 17 17:37:03 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 **/
@@ -987,8 +987,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;
   }



Mime
View raw message