Skip to content

Commit ca1f8a6

Browse files
author
Alena Prokharchyk
committed
CLOUDSTACK-3612: fixed missing indexes in some cloud tables. In the bug those tables are addressed as table apache#4, table apache#5, and table apache#6
Conflicts: setup/db/db/schema-410to420.sql
1 parent 226bed7 commit ca1f8a6

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public void performDataMigration(Connection conn) {
9898
migrateVolumeHostRef(conn);
9999
migrateTemplateHostRef(conn);
100100
migrateSnapshotStoreRef(conn);
101+
fixNiciraKeys(conn);
102+
fixRouterKeys(conn);
101103
}
102104

103105
private void fixBaremetalForeignKeys(Connection conn) {
@@ -1846,4 +1848,54 @@ private void migrateSnapshotStoreRef(Connection conn) {
18461848
}
18471849
}
18481850
}
1851+
1852+
private void fixNiciraKeys(Connection conn) {
1853+
//First drop the key if it exists.
1854+
List<String> keys = new ArrayList<String>();
1855+
s_logger.debug("Dropping foreign key fk_nicira_nvp_nic_map__nic from the table nicira_nvp_nic_map if it exists");
1856+
keys.add("fk_nicira_nvp_nic_map__nic");
1857+
DbUpgradeUtils.dropKeysIfExist(conn, "nicira_nvp_nic_map", keys, true);
1858+
1859+
//Now add foreign key.
1860+
PreparedStatement pstmt = null;
1861+
try {
1862+
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");
1863+
pstmt.executeUpdate();
1864+
s_logger.debug("Added foreign key fk_nicira_nvp_nic_map__nic to the table nicira_nvp_nic_map");
1865+
} catch (SQLException e) {
1866+
throw new CloudRuntimeException("Unable to add foreign key fk_nicira_nvp_nic_map__nic to the table nicira_nvp_nic_map", e);
1867+
} finally {
1868+
try {
1869+
if (pstmt != null) {
1870+
pstmt.close();
1871+
}
1872+
} catch (SQLException e) {
1873+
}
1874+
}
1875+
}
1876+
1877+
private void fixRouterKeys(Connection conn) {
1878+
//First drop the key if it exists.
1879+
List<String> keys = new ArrayList<String>();
1880+
s_logger.debug("Dropping foreign key fk_router_network_ref__router_id from the table router_network_ref if it exists");
1881+
keys.add("fk_router_network_ref__router_id");
1882+
DbUpgradeUtils.dropKeysIfExist(conn, "router_network_ref", keys, true);
1883+
1884+
//Now add foreign key.
1885+
PreparedStatement pstmt = null;
1886+
try {
1887+
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");
1888+
pstmt.executeUpdate();
1889+
s_logger.debug("Added foreign key fk_router_network_ref__router_id to the table router_network_ref");
1890+
} catch (SQLException e) {
1891+
throw new CloudRuntimeException("Unable to add foreign key fk_router_network_ref__router_id to the table router_network_ref", e);
1892+
} finally {
1893+
try {
1894+
if (pstmt != null) {
1895+
pstmt.close();
1896+
}
1897+
} catch (SQLException e) {
1898+
}
1899+
}
1900+
}
18491901
}

setup/db/db/schema-410to420.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,6 +2240,11 @@ CREATE VIEW `cloud`.`project_view` AS
22402240
and resource_tags.resource_type = 'Project'
22412241
left join
22422242
`cloud`.`project_account` pacct ON projects.id = pacct.project_id;
2243+
22432244
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)');
22442245

22452246
ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `concurrent_connections` int(10) unsigned COMMENT 'Load Balancer(haproxy) maximum number of concurrent connections(global max)';
2247+
2248+
2249+
ALTER TABLE `cloud`.`sync_queue` MODIFY `queue_size` smallint(6) NOT NULL DEFAULT '0' COMMENT 'number of items being processed by the queue';
2250+
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';

0 commit comments

Comments
 (0)