From ca1f8a663265e848562981a174ff68202df9f92f Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Thu, 18 Jul 2013 15:12:40 -0700 Subject: [PATCH] CLOUDSTACK-3612: fixed missing indexes in some cloud tables. In the bug those tables are addressed as table #4, table #5, and table #6 Conflicts: setup/db/db/schema-410to420.sql --- .../cloud/upgrade/dao/Upgrade410to420.java | 52 +++++++++++++++++++ setup/db/db/schema-410to420.sql | 5 ++ 2 files changed, 57 insertions(+) diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java index e37ccd525a6..2303ca8554e 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java @@ -98,6 +98,8 @@ public class Upgrade410to420 implements DbUpgrade { migrateVolumeHostRef(conn); migrateTemplateHostRef(conn); migrateSnapshotStoreRef(conn); + fixNiciraKeys(conn); + fixRouterKeys(conn); } private void fixBaremetalForeignKeys(Connection conn) { @@ -1846,4 +1848,54 @@ public class Upgrade410to420 implements DbUpgrade { } } } + + private void fixNiciraKeys(Connection conn) { + //First drop the key if it exists. + List keys = new ArrayList(); + s_logger.debug("Dropping foreign key fk_nicira_nvp_nic_map__nic from the table nicira_nvp_nic_map if it exists"); + keys.add("fk_nicira_nvp_nic_map__nic"); + DbUpgradeUtils.dropKeysIfExist(conn, "nicira_nvp_nic_map", keys, true); + + //Now add foreign key. + PreparedStatement pstmt = null; + try { + pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`nicira_nvp_nic_map` ADD CONSTRAINT `fk_nicira_nvp_nic_map__nic` FOREIGN KEY (`nic`) REFERENCES `nics` (`uuid`) ON DELETE CASCADE"); + pstmt.executeUpdate(); + s_logger.debug("Added foreign key fk_nicira_nvp_nic_map__nic to the table nicira_nvp_nic_map"); + } catch (SQLException e) { + throw new CloudRuntimeException("Unable to add foreign key fk_nicira_nvp_nic_map__nic to the table nicira_nvp_nic_map", e); + } finally { + try { + if (pstmt != null) { + pstmt.close(); + } + } catch (SQLException e) { + } + } + } + + private void fixRouterKeys(Connection conn) { + //First drop the key if it exists. + List keys = new ArrayList(); + s_logger.debug("Dropping foreign key fk_router_network_ref__router_id from the table router_network_ref if it exists"); + keys.add("fk_router_network_ref__router_id"); + DbUpgradeUtils.dropKeysIfExist(conn, "router_network_ref", keys, true); + + //Now add foreign key. + PreparedStatement pstmt = null; + try { + pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`router_network_ref` ADD CONSTRAINT `fk_router_network_ref__router_id` FOREIGN KEY (`router_id`) REFERENCES `domain_router` (`id`) ON DELETE CASCADE"); + pstmt.executeUpdate(); + s_logger.debug("Added foreign key fk_router_network_ref__router_id to the table router_network_ref"); + } catch (SQLException e) { + throw new CloudRuntimeException("Unable to add foreign key fk_router_network_ref__router_id to the table router_network_ref", e); + } finally { + try { + if (pstmt != null) { + pstmt.close(); + } + } catch (SQLException e) { + } + } + } } diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql index 3d4b835934c..c8ec7268e79 100644 --- a/setup/db/db/schema-410to420.sql +++ b/setup/db/db/schema-410to420.sql @@ -2240,6 +2240,11 @@ CREATE VIEW `cloud`.`project_view` AS and resource_tags.resource_type = 'Project' left join `cloud`.`project_account` pacct ON projects.id = pacct.project_id; + INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'network.loadbalancer.haproxy.max.conn', '4096', 'Load Balancer(haproxy) maximum number of concurrent connections(global max)'); ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `concurrent_connections` int(10) unsigned COMMENT 'Load Balancer(haproxy) maximum number of concurrent connections(global max)'; + + +ALTER TABLE `cloud`.`sync_queue` MODIFY `queue_size` smallint(6) NOT NULL DEFAULT '0' COMMENT 'number of items being processed by the queue'; +ALTER TABLE `cloud`.`sync_queue` MODIFY `queue_size_limit` smallint(6) NOT NULL DEFAULT '1' COMMENT 'max number of items the queue can process concurrently';