[ZBX-17176] Mysql upgrade failed from 4.0.16 to 4.4.4 Created: 2020 Jan 14 Updated: 2020 Jan 20 Resolved: 2020 Jan 20 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | None |
Affects Version/s: | 4.0.16 |
Fix Version/s: | None |
Type: | Problem report | Priority: | Trivial |
Reporter: | Konst | Assignee: | Edgars Melveris |
Resolution: | Commercial support required | Votes: | 0 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Centos 7 x64 |
Description |
Steps to reproduce:
Result: current database version (mandatory/optional): 04000000/04000004 Tried in mysql: ALTER TABLE `zabbix`.`dchecks` ADD CONSTRAINT `c_dchecks_1` FOREIGN KEY (`druleid`) REFERENCES `zabbix`.`drules` (`druleid`) ON DELETE CASCADE ON UPDATE RESTRICT; Error occured: ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`zabbix`.`#sql-b3e_c3fd`, CONSTRAINT `c_dchecks_1` FOREIGN KEY (`druleid`) REFERENCES `drules` (`druleid`) ON DELETE CASCADE ON UPDATE RESTRICT) |
Comments |
Comment by Edgars Melveris [ 2020 Jan 16 ] |
Hello Konst, please provide the output of the following command from DB CLI (if it's mysql): show create table dchecks \G Did you do any manual changes in the DB schema? |
Comment by Konst [ 2020 Jan 20 ] |
Hello! Server is old enough and two years ago DB crashed and was recovered to new server and may be something was lost during recovery. mysql> show create table dchecks \G Table: dchecks Create Table: CREATE TABLE `dchecks` ( `dcheckid` bigint unsigned NOT NULL, `druleid` bigint unsigned NOT NULL, `type` int NOT NULL DEFAULT '0', `key_` varchar(512) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `snmp_community` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `ports` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '0', `snmpv3_securityname` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `snmpv3_securitylevel` int NOT NULL DEFAULT '0', `snmpv3_authpassphrase` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `snmpv3_privpassphrase` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', `uniq` int NOT NULL DEFAULT '0', `snmpv3_authprotocol` int NOT NULL DEFAULT '0', `snmpv3_privprotocol` int NOT NULL DEFAULT '0', `snmpv3_contextname` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', PRIMARY KEY (`dcheckid`), KEY `dchecks_1` (`druleid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin 1 row in set (0.00 sec) |
Comment by Edgars Melveris [ 2020 Jan 20 ] |
The schema is incorrect, there should be a foreign key: CONSTRAINT `c_dchecks_1` FOREIGN KEY (`druleid`) REFERENCES `drules` (`druleid`) ON DELETE CASCADE You need to recreate it before you can continue with the upgrade. |