[ZBX-5288] Zabbix proxy does not work Created: 2012 Jul 07  Updated: 2017 May 30  Resolved: 2012 Aug 23

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Proxy (P)
Affects Version/s: 2.0.1
Fix Version/s: None

Type: Incident report Priority: Blocker
Reporter: Igor Novg Assignee: Unassigned
Resolution: Won't fix Votes: 0
Labels: dbpatches, upgrade
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu Linux 11.04 amd64, MySQL


Issue Links:
Duplicate
is duplicated by ZBX-7504 Adding a passive proxy fails with a f... Closed

 Description   

After updating zabbix proxy to version 2.0.1 (from 1.8.12) it refuses to update configuration from server:

9263:20120707:203204.581 Received configuration data from server. Datalen 151068
9263:20120707:203204.774 [Z3005] query failed: [1452] Cannot add or update a child row: a foreign key constraint fails (`zabbix`.`config`, CONSTRAINT `c_config_2` FOREIGN KEY (`discovery_groupid`) REFERENCES `groups` (`groupid`)) [insert into config (configid,refresh_unsupported,discovery_groupid,snmptrap_logging) values (1,600,0,1);]
9263:20120707:203204.774 failed to update local proxy cofiguration copy: database error

At first, i've upgraded the database using sql script from the sources. Then, after seeing this error, i've dropped the database and loaded it from the scratch from schema.sql,
but the error remained the same.

The server is 2.0.1 already and working fine.



 Comments   
Comment by richlv [ 2012 Jul 08 ]

when you dropped the db on proxy, what exact data did you insert in it (besides schema) ?

Comment by Igor Novg [ 2012 Jul 08 ]

I didn't insert anything, just did "mysql zabbix < database/mysql/schema.sql" and then launched zabbix_proxy.

Comment by dimir [ 2012 Aug 21 ]

Could you give the output of next queries on server database:

select * from groups where groupid = 0;
select configid,refresh_unsupported,discovery_groupid,snmptrap_logging from config;
show create table config;

Comment by Igor Novg [ 2012 Aug 21 ]
mysql> select * from groups where groupid = 0\G;
Empty set (0.00 sec)


mysql> select configid,refresh_unsupported,discovery_groupid,snmptrap_logging from config\G
*************************** 1. row ***************************
           configid: 1
refresh_unsupported: 600
  discovery_groupid: 0
   snmptrap_logging: 1
1 row in set (0.00 sec)


mysql> show create table config\G;
*************************** 1. row ***************************
       Table: config
Create Table: CREATE TABLE `config` (
  `configid` bigint(20) unsigned NOT NULL,
  `alert_history` int(11) NOT NULL DEFAULT '0',
  `event_history` int(11) NOT NULL DEFAULT '0',
  `refresh_unsupported` int(11) NOT NULL DEFAULT '0',
  `work_period` varchar(100) NOT NULL DEFAULT '1-5,00:00-24:00',
  `alert_usrgrpid` bigint(20) unsigned DEFAULT NULL,
  `event_ack_enable` int(11) NOT NULL DEFAULT '1',
  `event_expire` int(11) NOT NULL DEFAULT '7',
  `event_show_max` int(11) NOT NULL DEFAULT '100',
  `default_theme` varchar(128) NOT NULL DEFAULT 'originalblue',
  `authentication_type` int(11) NOT NULL DEFAULT '0',
  `ldap_host` varchar(255) NOT NULL DEFAULT '',
  `ldap_port` int(11) NOT NULL DEFAULT '389',
  `ldap_base_dn` varchar(255) NOT NULL DEFAULT '',
  `ldap_bind_dn` varchar(255) NOT NULL DEFAULT '',
  `ldap_bind_password` varchar(128) NOT NULL DEFAULT '',
  `ldap_search_attribute` varchar(128) NOT NULL DEFAULT '',
  `dropdown_first_entry` int(11) NOT NULL DEFAULT '1',
  `dropdown_first_remember` int(11) NOT NULL DEFAULT '1',
  `discovery_groupid` bigint(20) unsigned NOT NULL,
  `max_in_table` int(11) NOT NULL DEFAULT '50',
  `search_limit` int(11) NOT NULL DEFAULT '1000',
  `severity_color_0` varchar(6) NOT NULL DEFAULT 'DBDBDB',
  `severity_color_1` varchar(6) NOT NULL DEFAULT 'D6F6FF',
  `severity_color_2` varchar(6) NOT NULL DEFAULT 'FFF6A5',
  `severity_color_3` varchar(6) NOT NULL DEFAULT 'FFB689',
  `severity_color_4` varchar(6) NOT NULL DEFAULT 'FF9999',
  `severity_color_5` varchar(6) NOT NULL DEFAULT 'FF3838',
  `severity_name_0` varchar(32) NOT NULL DEFAULT 'Not classified',
  `severity_name_1` varchar(32) NOT NULL DEFAULT 'Information',
  `severity_name_2` varchar(32) NOT NULL DEFAULT 'Warning',
  `severity_name_3` varchar(32) NOT NULL DEFAULT 'Average',
  `severity_name_4` varchar(32) NOT NULL DEFAULT 'High',
  `severity_name_5` varchar(32) NOT NULL DEFAULT 'Disaster',
  `ok_period` int(11) NOT NULL DEFAULT '1800',
  `blink_period` int(11) NOT NULL DEFAULT '1800',
  `problem_unack_color` varchar(6) NOT NULL DEFAULT 'DC0000',
  `problem_ack_color` varchar(6) NOT NULL DEFAULT 'DC0000',
  `ok_unack_color` varchar(6) NOT NULL DEFAULT '00AA00',
  `ok_ack_color` varchar(6) NOT NULL DEFAULT '00AA00',
  `problem_unack_style` int(11) NOT NULL DEFAULT '1',
  `problem_ack_style` int(11) NOT NULL DEFAULT '1',
  `ok_unack_style` int(11) NOT NULL DEFAULT '1',
  `ok_ack_style` int(11) NOT NULL DEFAULT '1',
  `snmptrap_logging` int(11) NOT NULL DEFAULT '1',
  `server_check_interval` int(11) NOT NULL DEFAULT '60',
  PRIMARY KEY (`configid`),
  KEY `c_config_1` (`alert_usrgrpid`),
  KEY `c_config_2` (`discovery_groupid`),
  CONSTRAINT `c_config_1` FOREIGN KEY (`alert_usrgrpid`) REFERENCES `usrgrp` (`usrgrpid`),
  CONSTRAINT `c_config_2` FOREIGN KEY (`discovery_groupid`) REFERENCES `groups` (`groupid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
Comment by dimir [ 2012 Aug 22 ]

And what does next one return (also server database)?

select * from groups where internal=1;

Comment by Igor Novg [ 2012 Aug 22 ]

mysql> select * from groups where internal=1;
Empty set (0.00 sec)

Comment by dimir [ 2012 Aug 22 ]

Oh, nice. What about:

select * from groups;

If that is too big list could you paste it on some pastebin service?

Comment by Igor Novg [ 2012 Aug 22 ]
mysql> select * from groups;
+---------+-----------------------------------------+----------+
| groupid | name                                    | internal |
+---------+-----------------------------------------+----------+
|       1 | Templates                               |        0 |
|      10 | 10.5                                 |        0 |
|      11 | 10.4                       |        0 |
|      13 | 10.6                     |        0 |
|      15 | 10.8                     |        0 |
|      16 | 10.9                            |        0 |
|      17 | 10.10                          |        0 |
|      22 | 10.11                           |        0 |
|      23 | 10.12                           |        0 |
|      24 | 10.1 1                  |        0 |
|      25 | 10.1 2           |        0 |
|      26 | 10.1 3                      |        0 |
|      27 | 10.1 4          |        0 |
|      28 | 10.1 5                    |        0 |
|      29 | 10.1 6                        |        0 |
|      30 | 10.2 1           |        0 |
|      31 | 10.2 2          |        0 |
|      32 | 10.2 3                      |        0 |
|      33 | 10.2 4                    |        0 |
|      34 | 10.2 5                  |        0 |
|      35 | none                                    |        0 |
|      36 | 10.6                 |        0 |
+---------+-----------------------------------------+----------+
22 rows in set (0.00 sec)
Comment by dimir [ 2012 Aug 22 ]

Could you also give the output of this:

show variables like 'FOREIGN_KEY_CHECKS';

Comment by Igor Novg [ 2012 Aug 23 ]

It's on.

mysql> show variables like 'FOREIGN_KEY_CHECKS'\G
*************************** 1. row ***************************
Variable_name: foreign_key_checks
        Value: ON
1 row in set (0.00 sec)
Comment by dimir [ 2012 Aug 23 ]

Did you turn off foreign key checks at some point? Because this is the only way I could have unreferenced groupid in config table.

mysql> show variables like 'FOREIGN_KEY_CHECKS';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| foreign_key_checks | ON    |
+--------------------+-------+
1 row in set (0.00 sec)

mysql> select * from groups where groupid=0;
Empty set (0.04 sec)

mysql> insert into config (configid,refresh_unsupported,discovery_groupid,snmptrap_logging) values (1,600,0,1);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`dimir_test`.`config`, CONSTRAINT `c_config_2` FOREIGN KEY (`discovery_groupid`) REFERENCES `groups` (`groupid`))
mysql> SET FOREIGN_KEY_CHECKS = 0;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into config (configid,refresh_unsupported,discovery_groupid,snmptrap_logging) values (1,600,0,1);
Query OK, 1 row affected (0.04 sec)

mysql> SET FOREIGN_KEY_CHECKS = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> select configid,refresh_unsupported,discovery_groupid,snmptrap_logging from config;
+----------+---------------------+-------------------+------------------+
| configid | refresh_unsupported | discovery_groupid | snmptrap_logging |
+----------+---------------------+-------------------+------------------+
|        1 |                 600 |                 0 |                1 |
+----------+---------------------+-------------------+------------------+
1 row in set (0.00 sec)

So, when setting foreign key checks to on MySQL does not check constraints.

Comment by dimir [ 2012 Aug 23 ]

In order for you to fix the problem:

1) stop server and proxy
2) run next SQL queries on the server database

INSERT INTO `groups` (`groupid`,`name`,`internal`) values ('5','Discovered hosts','1');
UPDATE `config` set discovery_groupid=5;

3) empty (or recreate) proxy database
4) start server and proxy

The problem should go away.

Comment by Igor Novg [ 2012 Aug 23 ]

Yes, i think i have disabled them before running "upgrades/dbpatches/2.0/mysql/upgrade" (in patch.sql) because otherwise it failed to run complaining about foreign keys.

So it seems it had broke the constraints. Any idea how to fix it now?

Comment by dimir [ 2012 Aug 23 ]

Aaaah, you shouldn't have done that. You can try this:

http://stackoverflow.com/questions/2250775/force-innodb-to-recheck-foreign-keys-on-a-table-tables

In the future, if you have such errors, report them to us. I'm closing the bug now, feel free to re-open if you disagree.

Generated at Wed Apr 24 17:26:19 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.