[ZBX-5307] PHP runs out of memory when creating complex templates Created: 2012 Jul 11 Updated: 2017 May 30 Resolved: 2012 Aug 02 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | API (A), Frontend (F) |
Affects Version/s: | 2.1.0 |
Fix Version/s: | 2.0.3rc1, 2.1.0 |
Type: | Incident report | Priority: | Blocker |
Reporter: | Pavels Jelisejevs (Inactive) | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | database, dependencies, template, trigger | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Attachments: | zbx_export_templates(3).xml |
Description |
I have a template, that has two parent templates with trigger dependencies between the parent templates. When I'm trying to import the templates from zbx_export_templates(3).xml PHP runs out of memory. I suspect this is caused by trigger dependencies. Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 41 bytes) in /opt/lampp/htdocs/zabbix/trunk/frontends/php/include/classes/debug/CProfiler.php on line 232
After that the database becomes locked and an attempt to update something in the frontend results in errors like: Error in query [SELECT nextid FROM ids WHERE nodeid=0 AND table_name='hosts' AND field_name='hostid' FOR UPDATE] [Lock wait timeout exceeded; try restarting transaction] |
Comments |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Jul 30 ] |
In trunk r29197 PHP does not run out of memory, but the import fails with the following errors: Invalid argument supplied for foreach() [include/classes/import/CConfigurationImport.php:269] <pavels> The problem was that a trigger in the import file was dependent on a trigger, that did not exist in my configuration. That caused the final "Incorrect value "" for unsigned int field "triggerid_up"." error. The undefined indexes appeared, because item prototype applications were not being formatted properly. RESOLVED. |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Jul 31 ] |
The reason for the error is that now it's possible to create a dependency from a templated trigger, to the inherited trigger on a host, resulting in a circular dependency on the host trigger. I've added a validation rule to prevent such errors. RESOLVED. |
Comment by Toms (Inactive) [ 2012 Aug 01 ] |
(1) There is possibility to create incorrect dependency:
To see that this is wrong, you can try to open one of trigger within host and try saving it without changes. <pavels> RESOLVED. <Toms> CLOSED |
Comment by Toms (Inactive) [ 2012 Aug 01 ] |
(2) To not get an undefined index in foreach loop, there should be if statement prior that loop, not assigning empty array at some point elsewhere. plus CArrayHelper::convertFieldToArray($prototype, 'applications') in C20ImportFormatter.php line 304 makes unnecessary array_values(). <pavels> The whole point of the import formatter classes is to return imported data in a standard normalized form, so that import can handle it no matter what import format or version has been used. So if some import file does not contain some objects, it has to return an array, not an empty string, a null or whatever. The array_values() call is needed to reset the keys of the application array to zero based numeric case, from whatever format they may be given in. <Toms> OK, it's little overhead to get more structured format to not get any errors in future development. CLOSED |
Comment by Toms (Inactive) [ 2012 Aug 01 ] |
(3) CTrigger.php line 1821 ... $triggerTemplates = API::Template()->get(array( ... those are not trigger template but rather trigger dependency templates. following 'output' => array('status'), is unnecessery <pavels> RESOLVED. <Toms> CLOSED |
Comment by Toms (Inactive) [ 2012 Aug 01 ] |
(4) CTrigger.php line 1861 ... instead of get_hosts_by_triggerid() there should be a direct SQL function get_templates_by_triggerid() fetching only templates <pavels> RESOLVED. <Toms> CLOSED |
Comment by Toms (Inactive) [ 2012 Aug 01 ] |
(5) CTrigger.php line 1896 ... loop should be executed only if $setWithDep is true ... so it should be inside previous loop <pavels> RESOLVED. <Toms> CLOSED |
Comment by Toms (Inactive) [ 2012 Aug 01 ] |
(6) possible undefined $depTriggerIds in checkDependencyParents() $parentDepTriggers I have a feeling that this is more like dependency parent trigger, rather than parent dependency trigger <pavels> RESOLVED. <Toms> CLOSED |
Comment by Toms (Inactive) [ 2012 Aug 02 ] |
TESTED |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Aug 02 ] |
Fixed in 2.0.3rc1 r29382 and 2.1.0 r29382. CLOSED. |