Cannot Delete Object Types on Insight Asset Management due to database constraint violation exception in Jira Datacenter.
プラットフォームについて: Data Center - この記事は、Data Center プラットフォームのアトラシアン製品に適用されます。
このナレッジベース記事は製品の Data Center バージョン用に作成されています。Data Center 固有ではない機能の Data Center ナレッジベースは、製品のサーバー バージョンでも動作する可能性はありますが、テストは行われていません。サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。
*Fisheye および Crucible は除く
要約
While attempting to delete an object type, error with message "Something went wrong. Contact administrator" appears on the top right side of the screen, and the object type is not deleted.
環境
Insight versions above 8.4
診断
- In the GUI, the object type to be deleted has no attributes and objects.
- In atlassian-jira.log, SQL exceptions below during the object type deletion can be seen.
2021-07-12 10:58:09,072+0000 http-nio-8080-exec-21 ERROR admin 658x5404734x1 wjwkfb 10.0.0.1 /rest/insight/1.0/objecttype/1234 [c.r.j.p.i.services.core.ObjectTypeServiceImpl] RuntimeException:There was a SQL exception thrown by the Active Objects library:
Database:
- name:MySQL
- version:5.7.34
- minor version:7
- major version:5
Driver:
- name:MySQL Connector Java
- version:mysql-connector-java-5.1.47 ( Revision: fe1903b1ecb4a96a917f7ed3190d80c049b1de29 )
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`public`.`AO_8542F1_IFJ_OBJ`, CONSTRAINT `fk_ao_8542f1_ifj_obj_object_type_id` FOREIGN KEY (`OBJECT_TYPE_ID`) REFERENCES `AO_8542F1_IFJ_OBJ_TYPE` (`ID`))
com.atlassian.activeobjects.internal.ActiveObjectsSqlException: There was a SQL exception thrown by the Active Objects library:
Database:
- name:MySQL
- version:5.7.34
- minor version:7
- major version:5
Driver:
- name:MySQL Connector Java
- version:mysql-connector-java-5.1.47 ( Revision: fe1903b1ecb4a96a917f7ed3190d80c049b1de29 )
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`public`.`AO_8542F1_IFJ_OBJ`, CONSTRAINT `fk_ao_8542f1_ifj_obj_object_type_id` FOREIGN KEY (`OBJECT_TYPE_ID`) REFERENCES `AO_8542F1_IFJ_OBJ_TYPE` (`ID`))
at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.delete(EntityManagedActiveObjects.java:120)
at com.atlassian.activeobjects.osgi.TenantAwareActiveObjects.delete(TenantAwareActiveObjects.java:282)
原因
- Incomplete upgrade from Insight versions below 8.4. For some database types, there are some additional steps to be executed to change a table constraint before the upgrade as explained in Preparing for Insight Version 8.4.
This may happen when the first attempt to delete an object type fails due to race conditions or the deletion is interrupted in any way. There are some data in the database associated with the object type which has to be deleted first due to constraints.
ソリューション
For Cause 1, follow the steps in this page to fix the table constraints according to your database type.
For Cause 2, here are some SQL queries to be executed to check for data to be removed in order to allow the object type to be deleted successfully. Due to the table constraints, it's recommended to run the SELECT and DELETE queries following the order below.
データベースの変更を行う場合は必ず事前にバックアップを取得してください。可能な場合は、まずステージング サーバーで SQL コマンドの変更、挿入、更新、または削除を行うようにします。
These queries were written for MySQL and may have to be updated to work on another database:
Replace <object_type_id> with the ID of the object type to be deleted and execute all SQL queries below separately or as a script.
Object type ID can be retrieved from the URL in the GUI while browsing the object type e.g. <Jira_base_URL/secure/ObjectSchema.jspa?id=1&typeId=2&objectId=2.
- After deleting all rows returned from each SQL, it's recommended to restart Jira and run a clean re-index of Insight to ensure the index is updated.
- Now you can try to delete the object type from GUI again. The object type should be deleted successfully.