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:44 UTC
svn commit: r1185299 - in /hbase/branches/0.90: CHANGES.txt
src/main/java/org/apache/hadoop/hbase/KeyValue.java
Author: todd
Date: Mon Oct 17 17:36:43 2011
New Revision: 1185299
URL: http://svn.apache.org/viewvc?rev=1185299&view=rev
Log:
HBASE-4570. Fix a race condition that could cause inconsistent results from scans during concurrent writes.
Modified:
hbase/branches/0.90/CHANGES.txt
hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/KeyValue.java
Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1185299&r1=1185298&r2=1185299&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Mon Oct 17 17:36:43 2011
@@ -78,6 +78,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.90/src/main/java/org/apache/hadoop/hbase/KeyValue.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/KeyValue.java?rev=1185299&r1=1185298&r2=1185299&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/KeyValue.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/KeyValue.java Mon Oct 17 17:36:43 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 **/
@@ -892,8 +892,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;
}