[ZBX-10426] SQL errors during upgrade from 2.4 to 3.0 Created: 2016 Feb 20 Updated: 2017 May 30 Resolved: 2016 Feb 26 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S) |
Affects Version/s: | 3.0.0 |
Fix Version/s: | None |
Type: | Incident report | Priority: | Major |
Reporter: | Cristhian Carrera | Assignee: | Unassigned |
Resolution: | Won't fix | Votes: | 0 |
Labels: | dbpatches, upgrade | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Centos 7 zabbix server and centos 6.7 DataBase |
Description |
I installed zabbix 3.0 on centos 7 and I have to conect a DB mysq 5.6 (centos 6.7) in this DB is all my data, when the DB is connect, zabbix upgrate de database but display and error: "Can't create table 'zabbix.#sql-7e2d_3e' (errno: 150) [alter table application_prototype add constraint c_application_prototype_1 foreign key (itemid) references items (itemid) on delete cascade]" (zabbix.log) |
Comments |
Comment by Alexander Vladishev [ 2016 Feb 22 ] |
Perhaps your database is broken or has the wrong structure.
|
Comment by Cristhian Carrera [ 2016 Feb 22 ] |
Dear Alexander, all tables have InnoDB engine. |
Comment by Alexander Vladishev [ 2016 Feb 23 ] |
You can check it by command show create table <table_name>;. Field itemid must be `itemid` bigint(20) unsigned NOT NULL in both tables. Please attach a DB schema dump before an upgrade (mysqldump -d <database_name> | gzip -c > schema.dump.gz). |
Comment by Tyler Burns [ 2016 Feb 25 ] |
I had a similar issue except I am using postgres 9.4 on Debian Jessie. I was able to fix it myself though: 2016-02-25T08:57:28.582753-05:00 zabbix zabbix_server[1548]: [Z3005] query failed: [0] PGRES_FATAL_ERROR:ERROR: there is no unique constraint matching given keys for referenced table "applications"#012 [alter table application_discovery add constraint c_application_discovery_1 foreign key (applicationid) references applications (applicationid) on delete cascade] 2016-02-25T08:57:28.582839-05:00 zabbix zabbix_server[1548]: database upgrade failed I was able to fix it by adding the necessary constraint to the applications table: zabbix=# ALTER TABLE applications ADD CONSTRAINT constraint_name UNIQUE (applicationid); After I started the zabbix server again, the upgrade finished and the server started fine. |
Comment by Cristhian Carrera [ 2016 Feb 26 ] |
Dear Alexander, I check the tables and attach a DB schema dump before an upgrade: application_prototype | CREATE TABLE `application_prototype` ( `application_prototypeid` bigint(20) unsigned NOT NULL, items | CREATE TABLE `items` ( `itemid` bigint(20) unsigned NOT NULL, Now, display other error [Z3005] query failed: [1050] Table 'application_prototype' already exists [create table application_prototype ( application_prototypeid bigint unsigned not null, itemid bigint unsigned not null, templateid bigint unsigned, name varchar(255) default '' not null, primary key (application_prototypeid) ) engine=innodb] 23984:20160225:220228.783 database upgrade failed |
Comment by Oleksii Zagorskyi [ 2016 Feb 26 ] |
I can recall the Can't create table 'zabbix.#sql-RANDOM-CHARACTERS-HERE' error message every time when new major versions is released. I feel that it can happen for MySQL itself randomly, but it's not a problem of zabbix. Tyler, you have added constrain not according to zabbix schema, so don't be surprised that you will get some issues in future. Cristhian, your latest data shows that you did something wrong manually (looks like created table application_prototype manually). I think this issue also will be closed as won't fix. |
Comment by Cristhian Carrera [ 2016 Feb 26 ] |
Dear Oleksiy to perform the upgrade I returned to restore the database that I had; taking into account the recommendation of Alexander, the error message display in the logs after performing the upgrade I have not created any table or made any changes manually. |
Comment by Oleksii Zagorskyi [ 2016 Feb 26 ] |
Cristhian, Restoring from a mysql dump of previous version do not delete newly created tables, but it restores db patch level value. |
Comment by Oleksii Zagorskyi [ 2016 Feb 28 ] |
Thanks for closing it, but would be also nice to get a feedback how the initial problem was resolved. |
Comment by Cristhian Carrera [ 2016 Feb 28 ] |
Dear Oleksiy. To solve the first problem, I DROP zabbix DB and create the database again as if it were an initial installation, reviewing and taking into account the recommendations of Alexander Vladishev, after this restore DB; the second problem I resolved by DROP the tables that had error in my case were "application_prototype", "application_discovery" and "opinventory" after that the upgrade of zabbix DB was completed. I don't now the repercuriones will this future but it was the only way I found to resolve it. |
Comment by richlv [ 2016 Feb 29 ] |
...you should not have dropped any tables after the upgrade. but we're in the support area again, so please see http://zabbix.org/wiki/Getting_help |