HBASE-16801 The Append/Increment may return the data from future (ChiaPing Tsai)
This commit is contained in:
parent
bf03827196
commit
3830890635
|
@ -62,7 +62,7 @@ public class ServerNonceManager {
|
||||||
private static final long WAITING_BIT = 4;
|
private static final long WAITING_BIT = 4;
|
||||||
private static final long ALL_FLAG_BITS = WAITING_BIT | STATE_BITS;
|
private static final long ALL_FLAG_BITS = WAITING_BIT | STATE_BITS;
|
||||||
|
|
||||||
private long mvcc;
|
private volatile long mvcc;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -44,6 +44,27 @@ import org.mockito.stubbing.Answer;
|
||||||
@Category(SmallTests.class)
|
@Category(SmallTests.class)
|
||||||
public class TestServerNonceManager {
|
public class TestServerNonceManager {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMvcc() throws Exception {
|
||||||
|
ServerNonceManager nm = createManager();
|
||||||
|
final long group = 100;
|
||||||
|
final long nonce = 1;
|
||||||
|
final long initMvcc = 999;
|
||||||
|
assertTrue(nm.startOperation(group, nonce, createStoppable()));
|
||||||
|
nm.addMvccToOperationContext(group, nonce, initMvcc);
|
||||||
|
nm.endOperation(group, nonce, true);
|
||||||
|
assertEquals(initMvcc, nm.getMvccFromOperationContext(group, nonce));
|
||||||
|
long newMvcc = initMvcc + 1;
|
||||||
|
for (long newNonce = nonce + 1; newNonce != (nonce + 5); ++newNonce) {
|
||||||
|
assertTrue(nm.startOperation(group, newNonce, createStoppable()));
|
||||||
|
nm.addMvccToOperationContext(group, newNonce, newMvcc);
|
||||||
|
nm.endOperation(group, newNonce, true);
|
||||||
|
assertEquals(newMvcc, nm.getMvccFromOperationContext(group, newNonce));
|
||||||
|
++newMvcc;
|
||||||
|
}
|
||||||
|
assertEquals(initMvcc, nm.getMvccFromOperationContext(group, nonce));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNormalStartEnd() throws Exception {
|
public void testNormalStartEnd() throws Exception {
|
||||||
final long[] numbers = new long[] { NO_NONCE, 1, 2, Long.MAX_VALUE, Long.MIN_VALUE };
|
final long[] numbers = new long[] { NO_NONCE, 1, 2, Long.MAX_VALUE, Long.MIN_VALUE };
|
||||||
|
|
Loading…
Reference in New Issue