Bug 741729 - Add a general schema upgrade mechanism to cumin-admin
Summary: Add a general schema upgrade mechanism to cumin-admin
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: cumin
Version: 2.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: 2.1
: ---
Assignee: Trevor McKay
QA Contact: Jeff Needle
URL:
Whiteboard:
: 680266 (view as bug list)
Depends On:
Blocks: 743350
TreeView+ depends on / blocked
 
Reported: 2011-09-27 19:05 UTC by Trevor McKay
Modified: 2012-01-23 17:29 UTC (History)
3 users (show)

Fixed In Version: cumin-0.1.5033-1
Doc Type: Bug Fix
Doc Text:
Previously, the Cumin web console provided no facility to modify the schema of an existing database on a software upgrade. Consequently, if an upgrade included schema changes, users were required to drop and recreate the database to incorporate the new schema version. This resulted in loss of data. With this update, a new "cumin-admin upgrade-schema" command has been added that allows users to apply schema changes as part of a software upgrade. This command runs necessary scripts to upgrade the schema to the newest version without any loss of data. If there are no schema changes to apply, the user is be informed and no action is taken.
Clone Of:
Environment:
Last Closed: 2012-01-23 17:29:25 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2012:0045 0 normal SHIPPED_LIVE Red Hat Enterprise MRG Grid 2.1 bug fix and enhancement update 2012-01-23 22:22:58 UTC

Description Trevor McKay 2011-09-27 19:05:43 UTC
Description of problem:

From time to time we need to change the database schema used by Cumin.  To date, we have given users instructions in release notes on how to drop and recreate the cumin database.  This causes the loss of data and adds extra install tasks for the users.

We should have a general mechanism that allows users to upgrade the schema through a cumin-admin command when necessary.  Many schema changes can be handled easily via scripts without any data loss with this kind of mechanism

Comment 1 Trevor McKay 2011-09-27 20:45:02 UTC
Fixed in revision 5020.

Added the 'cumin-admin upgrade-schema' command.

This command will look in $CUMIN_HOME/model/upgrades (typically
/usr/share/cumin/model/upgrades) for scripts that can be run to upgrade an
existing cumin database to the schema version expected by the current cumin
install.

Scripts are named following the convention v1_to_v2 where v1 is the current
version and v2 is the target version and v1 and v2 will typically be of the
form Major.Minor

The command will look for a chain of files that can be executed to upgrade the
schema to the target version, and will prompt the user for confirmation.

The schema version number in the database will be updated after each script
completes successfully.  There is no rollback.  If a user cannot upgrade
successfully, then a drop and create of the database with loss of sample data
is the fallback (user database can usually be saved with export/import users).

Additionally, the cumin service start script will check for the expected schema
version and fail to start with a message if the version is not as expected.

A few ideas for testing upgrade-schema

The schema version can artificially be changed like the following 

$ echo UPDATE \"com.redhat.cumin\".\"Info\" SET schema_version = \'0.8\' | psql
-d cumin -U cumin -h localhost

Executable scripts with success or failure exit status can be created manually
in $CUMIN_HOME/model/upgrades, such as

0.1_to_0.2
0.2_to_0.3

and so on

Comment 2 Trevor McKay 2011-09-28 12:54:47 UTC
Tweaked in revision 5022, exception handler format corrected for Python 2.4

Comment 3 Trevor McKay 2011-09-28 13:21:50 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause
    Cumin provided no facility to modify the schema of an existing database on a software upgrade.

Consequence
    If an upgrade included schema changes, users were required to drop and recreate the database to incorporate the new schema version.  This resulted in loss of data.

Change
    A new 'cumin-admin upgrade-schema' command has been added that allows users to apply schema changes as part of a software upgrade.  This command will run necessary scripts to upgrade the schema to the newest version without loss of data.  If there are no schema changes to apply the user will be informed and no action will be taken.

Result
    Users may now safely run the 'cumin-admin upgrade-schema' command as a routine step in a software upgrade.

Comment 6 Jan Sarenik 2011-10-07 12:50:19 UTC
# rpm -q cumin
cumin-0.1.4916-1.el6.noarch
# service cumin stop
# yum update
# rpm -q cumin
cumin-0.1.5047-1.el6.noarch
# cumin-admin upgrade-schema
Attempting to upgrade the schema from 1.0 to 1.1
Found an update path.  Alter the schema? [yes]|no: 
Executing script /usr/share/cumin/model/upgrades/1.0_to_1.1
Upgrade to schema version 1.1 succeeded

Comment 7 Trevor McKay 2011-10-13 14:57:39 UTC
*** Bug 680266 has been marked as a duplicate of this bug. ***

Comment 9 Tomas Capek 2011-11-16 14:13:02 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,11 +1 @@
-Cause
+Previously, the Cumin web console provided no facility to modify the schema of an existing database on a software upgrade. Consequently, if an upgrade included schema changes, users were required to drop and recreate the database to incorporate the new schema version. This resulted in loss of data. With this update, a new "cumin-admin upgrade-schema" command has been added that allows users to apply schema changes as part of a software upgrade. This command runs necessary scripts to upgrade the schema to the newest version without any loss of data. If there are no schema changes to apply, the user is be informed and no action is taken.-    Cumin provided no facility to modify the schema of an existing database on a software upgrade.
-
-Consequence
-    If an upgrade included schema changes, users were required to drop and recreate the database to incorporate the new schema version.  This resulted in loss of data.
-
-Change
-    A new 'cumin-admin upgrade-schema' command has been added that allows users to apply schema changes as part of a software upgrade.  This command will run necessary scripts to upgrade the schema to the newest version without loss of data.  If there are no schema changes to apply the user will be informed and no action will be taken.
-
-Result
-    Users may now safely run the 'cumin-admin upgrade-schema' command as a routine step in a software upgrade.

Comment 10 errata-xmlrpc 2012-01-23 17:29:25 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2012-0045.html


Note You need to log in before you can comment on or make changes to this bug.