HBASE-4570. Fix a race condition that could cause inconsistent results from scans during concurrent writes.

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1185301 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2011-10-17 17:37:03 +00:00
parent ef6a0f9db3
commit ef6532498b
2 changed files with 9 additions and 3 deletions

View File

@ -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)

View File

@ -205,7 +205,7 @@ public class KeyValue implements Writable, HeapSize {
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 Writable, HeapSize {
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;
}