HBASE-16801 The Append/Increment may return the data from future (Chiaping Tsai)
This commit is contained in:
parent
7493e79f15
commit
0f21c41eda
|
@ -62,7 +62,7 @@ public class ServerNonceManager {
|
|||
private static final long WAITING_BIT = 4;
|
||||
private static final long ALL_FLAG_BITS = WAITING_BIT | STATE_BITS;
|
||||
|
||||
private static long mvcc;
|
||||
private long mvcc;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -45,6 +45,27 @@ import org.mockito.stubbing.Answer;
|
|||
@Category({RegionServerTests.class, SmallTests.class})
|
||||
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
|
||||
public void testNormalStartEnd() throws Exception {
|
||||
final long[] numbers = new long[] { NO_NONCE, 1, 2, Long.MAX_VALUE, Long.MIN_VALUE };
|
||||
|
|
Loading…
Reference in New Issue