cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [4/7] git commit: updated refs/heads/master to bcf7909
Date Wed, 24 Aug 2016 07:33:23 GMT
CLOUDSTACK-9466: Fix fk constraint failure in upgrade path

In the 4.1.0-4.2.0 db upgrade path, it creates new tables to store secondary
(nfs) storage in image_store table and volumes in volume_store_ref table. In
the upgrade path, it first tries to migrate NFS storage pool where it excludes
storage pools which have been removed, but it migrates all the volumes without
checking if their storage pools have been removed. This causes fk constraint
failure as the volume/row being inserted refers to a storage pool which does
not exist in the image_store table.

The fix migrates all the nfs storage pools to image_store including removed
storage pools and in doing so migrates with the 'removed' field. This fixes
db upgrade for old pre-4.0 and 4.0/4.1 CloudStack clouds.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7530f4b6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7530f4b6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7530f4b6

Branch: refs/heads/master
Commit: 7530f4b6dd98c18bceda3e1bf7790c0689ff5441
Parents: 740bd45
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Tue Aug 23 13:23:18 2016 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Wed Aug 24 12:03:46 2016 +0530

----------------------------------------------------------------------
 engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7530f4b6/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index b816fdc..80dbb55 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -1759,9 +1759,9 @@ public class Upgrade410to420 implements DbUpgrade {
                 PreparedStatement pstmtSelectSwiftCount = conn.prepareStatement(sqlSelectSwiftCount);
                 PreparedStatement storeDetailInsert = conn.prepareStatement(sqlInsertStoreDetail);
                 PreparedStatement storeInsert =
-                        conn.prepareStatement("INSERT INTO `cloud`.`image_store` (id, uuid,
name, image_provider_name, protocol, url, data_center_id, scope, role, parent, total_size,
created) values(?, ?, ?, 'NFS', 'nfs', ?, ?, 'ZONE', ?, ?, ?, ?)");
+                        conn.prepareStatement("INSERT INTO `cloud`.`image_store` (id, uuid,
name, image_provider_name, protocol, url, data_center_id, scope, role, parent, total_size,
created, removed) values(?, ?, ?, 'NFS', 'nfs', ?, ?, 'ZONE', ?, ?, ?, ?, ?)");
                 PreparedStatement nfsQuery =
-                        conn.prepareStatement("select id, uuid, url, data_center_id, parent,
total_size, created from `cloud`.`host` where type = 'SecondaryStorage' and removed is null");
+                        conn.prepareStatement("select id, uuid, url, data_center_id, parent,
total_size, created, removed from `cloud`.`host` where type = 'SecondaryStorage'");
                 PreparedStatement pstmtUpdateHostAsRemoved = conn.prepareStatement(sqlUpdateHostAsRemoved);
                 ResultSet rsSelectS3Count = pstmtSelectS3Count.executeQuery();
                 ResultSet rsSelectSwiftCount = pstmtSelectSwiftCount.executeQuery();
@@ -1796,6 +1796,7 @@ public class Upgrade410to420 implements DbUpgrade {
                 int nfs_dcid = rsNfs.getInt("data_center_id");
                 Long nfs_totalsize = rsNfs.getObject("total_size") != null ? rsNfs.getLong("total_size")
: null;
                 Date nfs_created = rsNfs.getDate("created");
+                Date nfs_removed = rsNfs.getDate("removed");
 
                 // insert entry in image_store table and image_store_details
                 // table and store host_id and store_id mapping
@@ -1812,6 +1813,7 @@ public class Upgrade410to420 implements DbUpgrade {
                     storeInsert.setNull(8, Types.BIGINT);
                 }
                 storeInsert.setDate(9, nfs_created);
+                storeInsert.setDate(10, nfs_removed);
                 storeInsert.executeUpdate();
             }
 


Mime
View raw message