HBASE-1954 Transactional scans do not see newest put
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@832526 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8cffa38ba3
commit
4531ccda91
|
@ -138,6 +138,14 @@ class TransactionState {
|
||||||
}
|
}
|
||||||
|
|
||||||
void addWrite(final Put write) {
|
void addWrite(final Put write) {
|
||||||
|
byte [] now = Bytes.toBytes(System.currentTimeMillis());
|
||||||
|
// HAVE to manually set the KV timestamps
|
||||||
|
for (List<KeyValue> kvs : write.getFamilyMap().values()) {
|
||||||
|
for (KeyValue kv : kvs) {
|
||||||
|
kv.updateLatestStamp(now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
puts.add(write);
|
puts.add(write);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,30 @@ public class TestTransactions extends HBaseClusterTestCase {
|
||||||
Assert.assertEquals(row2Value, Bytes.toInt(result.value()));
|
Assert.assertEquals(row2Value, Bytes.toInt(result.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testPutPutScan() throws IOException {
|
||||||
|
TransactionState transactionState = transactionManager.beginTransaction();
|
||||||
|
|
||||||
|
int row2Value = 199;
|
||||||
|
table.put(transactionState, new Put(ROW2).add(FAMILY, QUAL_A, Bytes
|
||||||
|
.toBytes(row2Value)));
|
||||||
|
|
||||||
|
row2Value = 299;
|
||||||
|
table.put(transactionState, new Put(ROW2).add(FAMILY, QUAL_A, Bytes
|
||||||
|
.toBytes(row2Value)));
|
||||||
|
|
||||||
|
ResultScanner scanner = table.getScanner(transactionState, new Scan()
|
||||||
|
.addFamily(FAMILY));
|
||||||
|
|
||||||
|
Result result = scanner.next();
|
||||||
|
Assert.assertNotNull(result);
|
||||||
|
Assert.assertEquals(Bytes.toString(ROW1), Bytes.toString(result.getRow()));
|
||||||
|
|
||||||
|
result = scanner.next();
|
||||||
|
Assert.assertNotNull(result);
|
||||||
|
Assert.assertEquals(Bytes.toString(ROW2), Bytes.toString(result.getRow()));
|
||||||
|
Assert.assertEquals(row2Value, Bytes.toInt(result.value()));
|
||||||
|
}
|
||||||
|
|
||||||
// Read from ROW1,COL_A and put it in ROW2_COLA and ROW3_COLA
|
// Read from ROW1,COL_A and put it in ROW2_COLA and ROW3_COLA
|
||||||
private TransactionState makeTransaction1() throws IOException {
|
private TransactionState makeTransaction1() throws IOException {
|
||||||
TransactionState transactionState = transactionManager.beginTransaction();
|
TransactionState transactionState = transactionManager.beginTransaction();
|
||||||
|
|
Loading…
Reference in New Issue