phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pbo...@apache.org
Subject [1/5] phoenix git commit: PHOENIX-4720 SequenceIT is flapping [Forced Update!]
Date Tue, 01 May 2018 21:51:41 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-cdh5.13 30443514b -> d1a0df37a (forced update)


PHOENIX-4720 SequenceIT is flapping


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

Branch: refs/heads/4.x-cdh5.13
Commit: 6b5ff317798981ba38d2cdcc37891d11d346d838
Parents: 4e0b3fb
Author: James Taylor <jtaylor@salesforce.com>
Authored: Mon Apr 30 19:50:34 2018 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Tue May 1 11:30:11 2018 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/SequenceIT.java  | 42 +++++++++++++++++++-
 .../coprocessor/SequenceRegionObserver.java     |  3 +-
 2 files changed, 43 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/6b5ff317/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java
index 9b870e1..4cc9628 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java
@@ -41,6 +41,7 @@ import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.schema.SchemaNotFoundException;
 import org.apache.phoenix.schema.SequenceAlreadyExistsException;
 import org.apache.phoenix.schema.SequenceNotFoundException;
+import org.apache.phoenix.util.EnvironmentEdge;
 import org.apache.phoenix.util.EnvironmentEdgeManager;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.PropertiesUtil;
@@ -90,6 +91,19 @@ public class SequenceIT extends ParallelStatsDisabledIT {
 		assertTrue(rs.next());
 	}
 
+    private static class MyClock extends EnvironmentEdge {
+        public volatile long time;
+
+        public MyClock (long time) {
+            this.time = time;
+        }
+
+        @Override
+        public long currentTime() {
+            return time;
+        }
+    }
+
 	@Test
 	public void testDuplicateSequences() throws Exception {
         String sequenceName = generateSequenceNameWithSchema();
@@ -105,7 +119,28 @@ public class SequenceIT extends ParallelStatsDisabledIT {
 		}
 	}
 
-	@Test
+    @Test
+    public void testDuplicateSequencesAtSameTimestamp() throws Exception {
+        final MyClock clock = new MyClock(1000);
+        EnvironmentEdgeManager.injectEdge(clock);
+        try {
+            String sequenceName = generateSequenceNameWithSchema();
+            
+            
+            conn.createStatement().execute("CREATE SEQUENCE " + sequenceName + " START WITH
2 INCREMENT BY 4\n");
+    
+            try {
+                conn.createStatement().execute("CREATE SEQUENCE " + sequenceName + " START
WITH 2 INCREMENT BY 4\n");
+                Assert.fail("Duplicate sequences");
+            } catch (SequenceAlreadyExistsException e){
+    
+            }
+        } finally {
+            EnvironmentEdgeManager.reset();
+        }
+    }
+
+    @Test
 	public void testSequenceNotFound() throws Exception {
         String sequenceName = generateSequenceNameWithSchema();
 		
@@ -753,26 +788,31 @@ public class SequenceIT extends ParallelStatsDisabledIT {
         assertSequenceValuesForSingleRow(sequenceName, 1, 2, 3);
         conn.createStatement().execute("DROP SEQUENCE " + sequenceName);
         
+        sequenceName = generateSequenceNameWithSchema();
         conn.createStatement().execute("CREATE SEQUENCE " + sequenceName + " INCREMENT BY
-1");
         
         assertSequenceValuesForSingleRow(sequenceName, 1, 0, -1);
         conn.createStatement().execute("DROP SEQUENCE " + sequenceName);
         
+        sequenceName = generateSequenceNameWithSchema();
         conn.createStatement().execute("CREATE SEQUENCE " + sequenceName + " MINVALUE 10");
         
         assertSequenceValuesForSingleRow(sequenceName, 10, 11, 12);
         conn.createStatement().execute("DROP SEQUENCE " + sequenceName);
         
+        sequenceName = generateSequenceNameWithSchema();
         conn.createStatement().execute("CREATE SEQUENCE " + sequenceName + " INCREMENT BY
-1 MINVALUE 10 ");
         
         assertSequenceValuesForSingleRow(sequenceName, Long.MAX_VALUE, Long.MAX_VALUE - 1,
Long.MAX_VALUE - 2);
         conn.createStatement().execute("DROP SEQUENCE " + sequenceName);
         
+        sequenceName = generateSequenceNameWithSchema();
         conn.createStatement().execute("CREATE SEQUENCE " + sequenceName + " MAXVALUE 0");
         
         assertSequenceValuesForSingleRow(sequenceName, Long.MIN_VALUE, Long.MIN_VALUE + 1,
Long.MIN_VALUE + 2);
         conn.createStatement().execute("DROP SEQUENCE " + sequenceName);
         
+        sequenceName = generateSequenceNameWithSchema();
         conn.createStatement().execute("CREATE SEQUENCE " + sequenceName + " INCREMENT BY
-1 MAXVALUE 0");
         
         assertSequenceValuesForSingleRow(sequenceName, 0, -1, -2);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/6b5ff317/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
index 6773f36..b768bc5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
@@ -364,7 +364,8 @@ public class SequenceRegionObserver extends BaseRegionObserver {
                     maxGetTimestamp = clientTimestamp + 1;
                 }            
             } else {
-                clientTimestamp = maxGetTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+                clientTimestamp = EnvironmentEdgeManager.currentTimeMillis();
+                maxGetTimestamp = clientTimestamp + 1;
                 clientTimestampBuf = Bytes.toBytes(clientTimestamp);
             }
         }


Mime
View raw message