[ 
https://issues.apache.org/jira/browse/PHOENIX-1641?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14310859#comment-14310859
 ] 

James Taylor commented on PHOENIX-1641:
---------------------------------------

Looks good, [~samarthjain]. Thanks for the addendum. One minor nit, instead of 
calculating the diff and adding it back to the old timestamp, just set it to 
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP (as your code isn't incorrect, but 
I think this is just simpler). +1 after that:
{code}
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java 
b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
index a92223b..4dbb1cf 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
@@ -220,14 +220,16 @@ public class UpgradeUtil {
                     preSplitSequenceTable(conn, nSaltBuckets);
                     return true;
                 }
-                // We can detect upgrade from 4.2.0 -> 4.2.1 based on the 
timestamp of the table row
-                if (oldTable.getTimeStamp() == 
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP-1) {
+                // If upgrading from 4.2.0, then we need this special case of 
pre-splitting the table.
+                // This is needed as a fix for 
https://issues.apache.org/jira/browse/PHOENIX-1401 
+                if (oldTable.getTimeStamp() == 
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_2_0) {
                     byte[] oldSeqNum = 
PLong.INSTANCE.toBytes(oldTable.getSequenceNumber());
+                    long systableTimestampDiff = 
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP - 
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_2_0;
                     KeyValue seqNumKV = KeyValueUtil.newKeyValue(seqTableKey, 
                             PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
                             PhoenixDatabaseMetaData.TABLE_SEQ_NUM_BYTES,
                             MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP,
-                            
PLong.INSTANCE.toBytes(oldTable.getSequenceNumber()+1));
+                            
PLong.INSTANCE.toBytes(oldTable.getSequenceNumber() + systableTimestampDiff));
                     Put seqNumPut = new Put(seqTableKey);
                     seqNumPut.add(seqNumKV);
                     // Increment TABLE_SEQ_NUM in checkAndPut as semaphore so 
that only single client
{code}

> Make the upgrade for SYSTEM.CATALOG and SYSTEM.SEQUENCE work for 4.x to 4.3
> ---------------------------------------------------------------------------
>
>                 Key: PHOENIX-1641
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1641
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Samarth Jain
>            Assignee: Samarth Jain
>             Fix For: 5.0.0, 4.3
>
>         Attachments: PHOENIX-1641.patch, PHOENIX-1641_v2.patch, 
> PHOENIX-1641_v3.patch
>
>
> The code got removed in the commit: 
> https://github.com/apache/phoenix/commit/58c80a1857659962d695bc8e5fe22b4e401b7f0a
>  



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to