[ZBX-15763] Zabbix server update failed 3.4 to 4.0.5 while automatic database upgrade Created: 2019 Mar 05  Updated: 2019 Mar 07  Resolved: 2019 Mar 07

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 4.0.5
Fix Version/s: None

Type: Problem report Priority: Critical
Reporter: Ivan Assignee: Zabbix Support Team
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

18.04.2 LTS (Bionic Beaver)
Linux zabbix 4.7.0-040700rc2-generic #201606051831 SMP Sun Jun 5 22:33:44 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

mysql Ver 15.1 Distrib 10.3.13-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2


Issue Links:
Duplicate
duplicates ZBX-11257 SQL Upgrade from 2.4.4 to 3.2.0 failed Closed

 Description   

128770:20190305:153458.209 query [txnlev:1] [begin;]
128770:20190305:153458.209 query [txnlev:1] [alter table `event_suppress` add constraint c_event_suppress_1 foreign key (`eventid`) references `events` (`eventid`) on delete cascade]
128770:20190305:153458.242 [Z3005] query failed: [1005] Can't create table `zabbix`.`event_suppress` (errno: 150 "Foreign key constraint is incorrectly formed") [alter table `event_suppress` add constraint c_event_suppress_1 foreign key (`eventid`) references `events` (`eventid`) on delete cascade]
128770:20190305:153458.242 query [alter table `event_suppress` add constraint c_event_suppress_1 foreign key (`eventid`) references `events` (`eventid`) on delete cascade] failed, setting transaction as failed
128770:20190305:153458.242 query [txnlev:1] [rollback;]
128770:20190305:153458.242 database upgrade failed



 Comments   
Comment by Ivan [ 2019 Mar 05 ]

1908:20190305:121956.148 Zabbix Server stopped. Zabbix 3.4.11 (revision 82160).
126770:20190305:123444.324 Starting Zabbix Server. Zabbix 4.0.5 (revision 90164).

Comment by Ivan [ 2019 Mar 05 ]

{{MariaDB [zabbix]> DESCRIBE events;

Field Type Null Key Default Extra
eventid bigint(20) unsigned NO PRI NULL  
source int(11) NO MUL 0  
object int(11) NO   0  
objectid bigint(20) unsigned NO   0  
clock int(11) NO PRI 0  
value int(11) NO   0  
acknowledged int(11) NO   0  
ns int(11) NO   0  
name varchar(2048) NO      
severity int(11) NO   0  

10 rows in set (0.002 sec)

MariaDB [zabbix]> DESCRIBE event_suppress;

Field Type Null Key Default Extra
event_suppressid bigint(20) unsigned NO PRI NULL  
eventid bigint(20) unsigned NO MUL NULL  
maintenanceid bigint(20) unsigned YES MUL NULL  
suppress_until int(11) NO MUL 0  

4 rows in set (0.001 sec)
}}

Comment by Ivan [ 2019 Mar 06 ]

When I trying to update through 3.4.15 - same result.

  1908:20190306:122151.322 Zabbix Server stopped. Zabbix 3.4.11 (revision 82160).
125353:20190306:122154.226 Starting Zabbix Server. Zabbix 3.4.15 (revision 86739).

  2907:20190306:123212.973 Starting Zabbix Server. Zabbix 4.0.5 (revision 90164).
....
  2907:20190306:123506.407 completed 77% of database upgrade
  2907:20190306:123506.438 completed 78% of database upgrade
  2907:20190306:123506.444 completed 79% of database upgrade
  2907:20190306:123506.455 [Z3005] query failed: [1005] Can't create table `zabbix`.`event_suppress` (errno: 150 "Foreign key constraint is incorrectly formed") [alter table `event_suppress` add constraint c_eve
nt_suppress_1 foreign key (`eventid`) references `events` (`eventid`) on delete cascade]
  2907:20190306:123506.455 database upgrade failed
  2978:20190306:123516.647 Starting Zabbix Server. Zabbix 4.0.5 (revision 90164).

 

Comment by Aigars Kadikis [ 2019 Mar 06 ]

Hello Ivan,

Thank you for registering this ticket.

This is not a bug. On vanilla 3.4 instance while using everything according to the manual there will be no such issue.

A custom support case can help pass this issue. I will close the ticket as Commercial support required.

Regards,
Aigars

Comment by Ivan [ 2019 Mar 06 ]

Step by step i follow this instruction:

https://www.zabbix.com/documentation/4.0/manual/installation/upgrade/packages/debian_ubuntu

and got same error...

 

Comment by Ivan [ 2019 Mar 06 ]

Or may be you implying that I have not vanilla 3.4 instance?

Comment by Glebs Ivanovskis [ 2019 Mar 06 ]

Can you show the following?

select * from dbversion;
show create table events\G
show create table event_suppress\G
Comment by Ivan [ 2019 Mar 07 ]

{{
select * from dbversion;

mandatory optional
3050132 3050132

1 row in set (0.001 sec)

show create table events\G

Table: events
Create Table: CREATE TABLE `events` (
`eventid` bigint(20) unsigned NOT NULL,
`source` int(11) NOT NULL DEFAULT 0,
`object` int(11) NOT NULL DEFAULT 0,
`objectid` bigint(20) unsigned NOT NULL DEFAULT 0,
`clock` int(11) NOT NULL DEFAULT 0,
`value` int(11) NOT NULL DEFAULT 0,
`acknowledged` int(11) NOT NULL DEFAULT 0,
`ns` int(11) NOT NULL DEFAULT 0,
`name` varchar(2048) NOT NULL DEFAULT '',
`severity` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`eventid`,`clock`),
KEY `events_1` (`source`,`object`,`objectid`,`clock`) USING BTREE,
KEY `events_2` (`source`,`object`,`clock`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8
PARTITION BY RANGE (`clock`)
(PARTITION `p_mart18` VALUES LESS THAN (1525046400) COMMENT = 'Март 2018' ENGINE = InnoDB,
PARTITION `p_may01_18` VALUES LESS THAN (1526342400) COMMENT = 'Май 2018 первая половина' ENGINE = InnoDB,
PARTITION `p_may15_18` VALUES LESS THAN (1527811200) COMMENT = 'Май 2018 вторая половина' ENGINE = InnoDB,
PARTITION `p_june01_18` VALUES LESS THAN (1529020800) COMMENT = 'Июнь 2018 первая половина' ENGINE = InnoDB,
PARTITION `p_june15_18` VALUES LESS THAN (1530403200) COMMENT = 'Июнь 2018 вторая половина' ENGINE = InnoDB,
PARTITION `p_jule01_18` VALUES LESS THAN (1531612800) COMMENT = 'Июль 2018 первая половина' ENGINE = InnoDB,
PARTITION `p_jule15_18` VALUES LESS THAN (1533081600) COMMENT = 'Июль 2018 вторая половина' ENGINE = InnoDB,
PARTITION `pMAXVALUE` VALUES LESS THAN MAXVALUE COMMENT = 'Текущий месяц' ENGINE = InnoDB)
1 row in set (0.001 sec)

 

show create table event_suppress\G

Table: event_suppress
Create Table: CREATE TABLE `event_suppress` (
`event_suppressid` bigint(20) unsigned NOT NULL,
`eventid` bigint(20) unsigned NOT NULL,
`maintenanceid` bigint(20) unsigned DEFAULT NULL,
`suppress_until` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`event_suppressid`),
UNIQUE KEY `event_suppress_1` (`eventid`,`maintenanceid`),
KEY `event_suppress_2` (`suppress_until`),
KEY `event_suppress_3` (`maintenanceid`)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
1 row in set (0.000 sec)
}}

Comment by Ivan [ 2019 Mar 07 ]

Hm... I made
ALTER TABLE events REMOVE PARTITIONING;
And it helped! cyclone, thanks for the tip!

Comment by Glebs Ivanovskis [ 2019 Mar 07 ]

I did nothing!
Glad you've solved the problem.

The issue can be considered a duplicate of ZBX-11257.

Generated at Wed Jul 16 11:24:22 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.