From eaf9d3d820a9dadb299f4ccc913654bc61ce6411 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Tue, 24 Apr 2012 15:47:50 -0700 Subject: [PATCH] Catch all exceptions when change engine and row_format - can fail when table is full. Just skip as its not a critical fix --- .../cloud/upgrade/dao/Upgrade301to302.java | 36 +++++++++++++++++++ setup/db/db/schema-301to302.sql | 5 --- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/server/src/com/cloud/upgrade/dao/Upgrade301to302.java b/server/src/com/cloud/upgrade/dao/Upgrade301to302.java index a9612da3d77..8a0df6f6563 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade301to302.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade301to302.java @@ -75,6 +75,7 @@ public class Upgrade301to302 implements DbUpgrade { dropKeysIfExists(conn); updateSharedNetworks(conn); fixLastHostIdKey(conn); + changeEngine(conn); } @Override @@ -188,4 +189,39 @@ public class Upgrade301to302 implements DbUpgrade { } } } + + private void changeEngine(Connection conn) { + s_logger.debug("Fixing engine and row_format for op_lock and op_nwgrp_work tables"); + PreparedStatement pstmt = null; + try { + pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`op_lock` ENGINE=MEMORY, ROW_FORMAT = FIXED"); + pstmt.executeUpdate(); + pstmt.close(); + } catch (Exception e) { + s_logger.debug("Failed do execute the statement " + pstmt + ", moving on as it's not critical fix"); + } finally { + try { + if (pstmt != null) { + pstmt.close(); + } + } catch (SQLException e) { + } + } + + try { + pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`op_nwgrp_work` ENGINE=MEMORY, ROW_FORMAT = FIXED"); + pstmt.executeUpdate(); + pstmt.close(); + } catch (Exception e) { + s_logger.debug("Failed do execute the statement " + pstmt + ", moving on as it's not critical fix"); + } finally { + try { + if (pstmt != null) { + pstmt.close(); + } + } catch (SQLException e) { + } + } + } + } diff --git a/setup/db/db/schema-301to302.sql b/setup/db/db/schema-301to302.sql index 25756275956..25284246fb9 100755 --- a/setup/db/db/schema-301to302.sql +++ b/setup/db/db/schema-301to302.sql @@ -27,10 +27,5 @@ UPDATE `cloud`.`network_offerings` SET display_text='Offering for Isolated netwo UPDATE `cloud`.`network_offerings` SET display_text='Offering for Isolated networks with no Source Nat service' WHERE name='DefaultIsolatedNetworkOffering' and `cloud`.`network_offerings`.default=1; UPDATE `cloud`.`network_offerings` SET display_text='Offering for Shared networks' WHERE name='DefaultSharedNetworkOffering' and `cloud`.`network_offerings`.default=1; - - -ALTER TABLE `cloud`.`op_lock` ENGINE=MEMORY, ROW_FORMAT = FIXED; -ALTER TABLE `cloud`.`op_nwgrp_work` ENGINE=MEMORY, ROW_FORMAT = FIXED; - INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('XenServer', '6.0.2', 50, 1); INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES ('VMware', '5.0', 128, 0);