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

James Taylor commented on PHOENIX-808:
--------------------------------------

Thanks for the patch, [~samarthjain]. Here's some feedback:
- In general, restoring multiple system tables is tricky. For example, keeping 
the new system.catalog might not be good if the upgrading of the 
system.sequence fails. For simplicity, I'd stick with solely 
snapshoting/restoring only the system.catalog and revert back to the old one if 
any anything fails across the upgrade of any of the system tables.
- How about we just remove the upgrade code in both system.sequence and 
system.stats? The upgrade code there is way older than anything our b/w compat 
contract supports (all the way five version back to 4.2 and 4.3). The sequence 
upgrade is a noop now too, since by default we don't salt the sequence table. 
That way, there's no upgrade anyway for the other tables.
- Might be best to put the enableTable here in a finally block so that if the 
restore were to fail we'd still leave the table in an enabled state:
{code}
+                private void restoreFromSnapshot(String tableName, String 
snapshotName,
+                        boolean success) throws IOException, 
RestoreSnapshotException, SQLException {
+                    if (!success && snapshotName != null) {
+                        try (HBaseAdmin admin = getAdmin()) {
+                            logger.warn("Starting restore of " + tableName + " 
using snapshot " + snapshotName + " because upgrade failed");
+                            admin.disableTable(tableName);
+                            admin.restoreSnapshot(snapshotName);
+                            admin.enableTable(tableName);
+                            logger.warn("Successfully restored " + tableName + 
" using snapshot " + snapshotName);
+                        }
+                    }
+                }
{code}

> Create snapshot of system tables prior to upgrade and restore on any failure
> ----------------------------------------------------------------------------
>
>                 Key: PHOENIX-808
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-808
>             Project: Phoenix
>          Issue Type: Task
>            Reporter: James Taylor
>            Assignee: Samarth Jain
>         Attachments: PHOENIX-808.patch, PHOENIX-808_master.patch, 
> PHOENIX-808_nowhitespace.patch
>
>




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

Reply via email to