HBASE-3494 checkAndPut implementation doesnt verify row param and writable row are the same
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1066149 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9b0a004017
commit
6b30bf2a09
|
@ -34,7 +34,8 @@ Release 0.91.0 - Unreleased
|
||||||
causing data loss during recovery
|
causing data loss during recovery
|
||||||
HBASE-3493 HMaster sometimes hangs during initialization due to missing
|
HBASE-3493 HMaster sometimes hangs during initialization due to missing
|
||||||
notify call (Bruno Dumon via Stack)
|
notify call (Bruno Dumon via Stack)
|
||||||
|
HBASE-3494 checkAndPut implementation doesnt verify row param and writable
|
||||||
|
row are the same
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
HBASE-2001 Coprocessors: Colocate user code with regions (Mingjie Lai via
|
HBASE-2001 Coprocessors: Colocate user code with regions (Mingjie Lai via
|
||||||
|
|
|
@ -69,6 +69,7 @@ import org.apache.hadoop.hbase.client.Get;
|
||||||
import org.apache.hadoop.hbase.client.Increment;
|
import org.apache.hadoop.hbase.client.Increment;
|
||||||
import org.apache.hadoop.hbase.client.Put;
|
import org.apache.hadoop.hbase.client.Put;
|
||||||
import org.apache.hadoop.hbase.client.Result;
|
import org.apache.hadoop.hbase.client.Result;
|
||||||
|
import org.apache.hadoop.hbase.client.Row;
|
||||||
import org.apache.hadoop.hbase.client.RowLock;
|
import org.apache.hadoop.hbase.client.RowLock;
|
||||||
import org.apache.hadoop.hbase.client.Scan;
|
import org.apache.hadoop.hbase.client.Scan;
|
||||||
import org.apache.hadoop.hbase.client.coprocessor.Exec;
|
import org.apache.hadoop.hbase.client.coprocessor.Exec;
|
||||||
|
@ -1635,7 +1636,11 @@ public class HRegion implements HeapSize { // , Writable{
|
||||||
checkResources();
|
checkResources();
|
||||||
boolean isPut = w instanceof Put;
|
boolean isPut = w instanceof Put;
|
||||||
if (!isPut && !(w instanceof Delete))
|
if (!isPut && !(w instanceof Delete))
|
||||||
throw new IOException("Action must be Put or Delete");
|
throw new DoNotRetryIOException("Action must be Put or Delete");
|
||||||
|
Row r = (Row)w;
|
||||||
|
if (Bytes.compareTo(row, r.getRow()) != 0) {
|
||||||
|
throw new DoNotRetryIOException("Action's getRow must match the passed row");
|
||||||
|
}
|
||||||
|
|
||||||
startRegionOperation();
|
startRegionOperation();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
|
import org.apache.hadoop.hbase.DoNotRetryIOException;
|
||||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||||
import org.apache.hadoop.hbase.HBaseTestCase;
|
import org.apache.hadoop.hbase.HBaseTestCase;
|
||||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
|
@ -96,6 +97,8 @@ public class TestHRegion extends HBaseTestCase {
|
||||||
protected final byte[] value1 = Bytes.toBytes("value1");
|
protected final byte[] value1 = Bytes.toBytes("value1");
|
||||||
protected final byte[] value2 = Bytes.toBytes("value2");
|
protected final byte[] value2 = Bytes.toBytes("value2");
|
||||||
protected final byte [] row = Bytes.toBytes("rowA");
|
protected final byte [] row = Bytes.toBytes("rowA");
|
||||||
|
protected final byte [] row2 = Bytes.toBytes("rowB");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.hadoop.hbase.HBaseTestCase#setUp()
|
* @see org.apache.hadoop.hbase.HBaseTestCase#setUp()
|
||||||
|
@ -605,6 +608,20 @@ public class TestHRegion extends HBaseTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCheckAndPut_wrongRowInPut() throws IOException {
|
||||||
|
initHRegion(tableName, this.getName(), COLUMNS);
|
||||||
|
|
||||||
|
Put put = new Put(row2);
|
||||||
|
put.add(fam1, qual1, value1);
|
||||||
|
try {
|
||||||
|
boolean res = region.checkAndMutate(row,
|
||||||
|
fam1, qual1, value2, put, null, false);
|
||||||
|
fail();
|
||||||
|
} catch (DoNotRetryIOException expected) {
|
||||||
|
// expected exception.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testCheckAndDelete_ThatDeleteWasWritten() throws IOException{
|
public void testCheckAndDelete_ThatDeleteWasWritten() throws IOException{
|
||||||
byte [] tableName = Bytes.toBytes("testtable");
|
byte [] tableName = Bytes.toBytes("testtable");
|
||||||
byte [] row1 = Bytes.toBytes("row1");
|
byte [] row1 = Bytes.toBytes("row1");
|
||||||
|
|
Loading…
Reference in New Issue