gjacoby126 commented on a change in pull request #473: PHOENIX-5138 - 
ViewIndexId sequences created after PHOENIX-5132 shoul…
URL: https://github.com/apache/phoenix/pull/473#discussion_r273275519
 
 

 ##########
 File path: 
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
 ##########
 @@ -2502,6 +2483,32 @@ public void createTable(RpcController controller, 
CreateTableRequest request,
         }
     }
 
+    private long getViewIndexSequenceValue(PhoenixConnection connection, 
String tenantIdStr, PTable parentTable, PName physicalName) throws SQLException 
{
+        int nSequenceSaltBuckets = 
connection.getQueryServices().getSequenceSaltBuckets();
+
+        SequenceKey key = MetaDataUtil.getViewIndexSequenceKey(tenantIdStr, 
physicalName,
+            nSequenceSaltBuckets, parentTable.isNamespaceMapped() );
+        // Earlier sequence was created at (SCN-1/LATEST_TIMESTAMP) and 
incremented at the client max(SCN,dataTable.getTimestamp), but it seems we 
should
+        // use always LATEST_TIMESTAMP to avoid seeing wrong sequence values 
by different connection having SCN
+        // or not.
+        long sequenceTimestamp = HConstants.LATEST_TIMESTAMP;
+        try {
+            connection.getQueryServices().createSequence(key.getTenantId(), 
key.getSchemaName(), key.getSequenceName(),
+                Long.MIN_VALUE, 1, 1, Long.MIN_VALUE, Long.MAX_VALUE, false, 
sequenceTimestamp);
+        } catch (SequenceAlreadyExistsException e) {
+        }
 
 Review comment:
   The logic here is essentially "CREATE SEQUENCE Foo IF NOT EXISTS", so the 
fact that it already exists isn't really relevant, which is why we eat the 
exception. I'm going to add a comment saying so. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to