> On Oct. 12, 2017, 9:01 a.m., Nate Cole wrote: > > ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog260.java > > Lines 217-222 (patched) > > <https://reviews.apache.org/r/62931/diff/1/?file=1853309#file1853309line217> > > > > Should these oddly named FKs go in a try/catch since they're not ALWAYS > > present? > > Jonathan Hurley wrote: > I think the dropConstraint queries first before it drops it, so that if > it doesn't exist it won't throw an exception. > > Nate Cole wrote: > They all throw SQLException which implies something can go wrong.
``` String checkedConstraintName = getCheckedForeignKey(convertObjectName(tableName), constraintName); if (checkedConstraintName != null) { ``` It can throw a SQL exception, but it won't throw one if it's missing. - Jonathan ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/62931/#review187784 ----------------------------------------------------------- On Oct. 12, 2017, 8:29 a.m., Dmitro Lisnichenko wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/62931/ > ----------------------------------------------------------- > > (Updated Oct. 12, 2017, 8:29 a.m.) > > > Review request for Ambari, Jonathan Hurley and Nate Cole. > > > Bugs: AMBARI-22216 > https://issues.apache.org/jira/browse/AMBARI-22216 > > > Repository: ambari > > > Description > ------- > > For now, patch with workaround for issue on QA cluster. > > Ambari Schema Upgrade Failed, Upgrade from : 2510 to 2600 (Also seen from > 2430 to 2600) > ambari-server.log > {code} > 03 Oct 2017 06:30:26,349 INFO [main] DBAccessorImpl:874 - Executing query: > ALTER TABLE servicecomponentdesiredstate ADD desired_repo_version_id BIGINT > NOT NULL DEFAULT 1 > 03 Oct 2017 06:30:26,389 INFO [main] DBAccessorImpl:874 - Executing query: > ALTER TABLE servicecomponentdesiredstate MODIFY desired_repo_version_id > BIGINT > 03 Oct 2017 06:30:26,435 INFO [main] DBAccessorImpl:874 - Executing query: > ALTER TABLE servicecomponentdesiredstate MODIFY desired_repo_version_id > BIGINT NOT NULL > 03 Oct 2017 06:30:26,490 INFO [main] DBAccessorImpl:874 - Executing query: > ALTER TABLE servicecomponentdesiredstate ADD repo_state VARCHAR(255) NOT NULL > DEFAULT 'CURRENT' > 03 Oct 2017 06:30:26,549 INFO [main] DBAccessorImpl:874 - Executing query: > ALTER TABLE servicecomponentdesiredstate MODIFY repo_state VARCHAR(255) > 03 Oct 2017 06:30:26,598 INFO [main] DBAccessorImpl:874 - Executing query: > ALTER TABLE servicecomponentdesiredstate MODIFY repo_state VARCHAR(255) NOT > NULL > 03 Oct 2017 06:30:26,742 INFO [main] DBAccessorImpl:874 - Executing query: > ALTER TABLE servicecomponentdesiredstate ADD CONSTRAINT > FK_scds_desired_repo_id FOREIGN KEY (desired_repo_version_id) REFERENCES > repo_version (repo_version_id) > 03 Oct 2017 06:30:26,782 INFO [main] DBAccessorImpl:874 - Executing query: > ALTER TABLE servicecomponentdesiredstate DROP FOREIGN KEY > FK_scds_desired_stack_id > 03 Oct 2017 06:30:26,802 INFO [main] DBAccessorImpl:874 - Executing query: > ALTER TABLE servicecomponentdesiredstate DROP COLUMN desired_stack_id > 03 Oct 2017 06:30:26,817 ERROR [main] DBAccessorImpl:880 - Error executing > query: ALTER TABLE servicecomponentdesiredstate DROP COLUMN desired_stack_id > java.sql.SQLException: Cannot drop index > 'FK_servicecomponentdesiredstate_desired_stack_id': needed in a foreign key > constraint > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996) > at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3887) > at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3823) > at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435) > at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582) > at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2526) > at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2484) > at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:848) > at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:742) > at > org.apache.ambari.server.orm.DBAccessorImpl.executeQuery(DBAccessorImpl.java:877) > at > org.apache.ambari.server.orm.DBAccessorImpl.executeQuery(DBAccessorImpl.java:869) > at > org.apache.ambari.server.orm.DBAccessorImpl.dropColumn(DBAccessorImpl.java:974) > at > org.apache.ambari.server.upgrade.UpgradeCatalog260.updateServiceComponentDesiredStateTable(UpgradeCatalog260.java:386) > at > org.apache.ambari.server.upgrade.UpgradeCatalog260.executeDDLUpdates(UpgradeCatalog260.java:185) > at > org.apache.ambari.server.upgrade.AbstractUpgradeCatalog.upgradeSchema(AbstractUpgradeCatalog.java:923) > at > org.apache.ambari.server.upgrade.SchemaUpgradeHelper.executeUpgrade(SchemaUpgradeHelper.java:200) > at > org.apache.ambari.server.upgrade.SchemaUpgradeHelper.main(SchemaUpgradeHelper.java:418) > 03 Oct 2017 06:30:26,822 ERROR [main] SchemaUpgradeHelper:202 - Upgrade > failed. > {code} > > > Diffs > ----- > > > ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog260.java > 5a24bbb22b > > > Diff: https://reviews.apache.org/r/62931/diff/1/ > > > Testing > ------- > > mvn clean test > > > Thanks, > > Dmitro Lisnichenko > >