hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-16801 The Append/Increment may return the data from future (ChiaPing Tsai)
Date Wed, 12 Oct 2016 17:07:44 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 bf0382719 -> 383089063


HBASE-16801 The Append/Increment may return the data from future (ChiaPing Tsai)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/38308906
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/38308906
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/38308906

Branch: refs/heads/branch-1
Commit: 3830890635261c9eccd7ceeff8ad1b95e3714cd6
Parents: bf03827
Author: tedyu <yuzhihong@gmail.com>
Authored: Wed Oct 12 10:07:37 2016 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Wed Oct 12 10:07:37 2016 -0700

----------------------------------------------------------------------
 .../hbase/regionserver/ServerNonceManager.java  |  2 +-
 .../regionserver/TestServerNonceManager.java    | 21 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/38308906/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ServerNonceManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ServerNonceManager.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ServerNonceManager.java
index bd9dad9..1e1a9a9 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ServerNonceManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ServerNonceManager.java
@@ -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 long mvcc;
+    private volatile long mvcc;
 
     @Override
     public String toString() {

http://git-wip-us.apache.org/repos/asf/hbase/blob/38308906/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerNonceManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerNonceManager.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerNonceManager.java
index 940f715..6bf1721 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerNonceManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerNonceManager.java
@@ -45,6 +45,27 @@ import org.mockito.stubbing.Answer;
 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 };
     ServerNonceManager nm = createManager();


Mime
View raw message