[ZBX-10842] httptest.update fails when updating steps without httpstepid Created: 2016 May 24 Updated: 2017 May 30 Resolved: 2016 Oct 17 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | API (A) |
Affects Version/s: | 3.0.3 |
Fix Version/s: | 2.2.16rc1, 3.0.6rc1, 3.2.2rc1, 3.4.0alpha1 |
Type: | Incident report | Priority: | Blocker |
Reporter: | Marián Černý | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | webmonitoring | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
FreeBSD |
Attachments: | zabbix-CHttpTestManager.php.diff | ||||||||
Issue Links: |
|
Description |
When I create an http test using httptest.create and then try to update the test with exact same data using httptest.update, the update fails with the following DB error: Zabbix error in request: '{"jsonrpc":"2.0","method":"httptest.update","params":{"httptestid":"5","hostid":"10149","applicationid":"973","name":"Sensor17: test.cz","agent":"Mozilla ]},"auth":"559aa0854bf2540f6656235401008f95","id":6}' Response: array ( 'code' => -32500, 'message' => 'Application error.', 'data' => 'SQL statement execution has failed "INSERT INTO items_applications (applicationid,itemid,itemappid) VALUES (\'973\',\'27679\',\'13296\')".', ) More precisely it fails on duplicate key 13296 for itemappid. I have tried to track down the error and here is the top of the stack trace from the exception: exception 'DBException' with message 'SQL statement execution has failed "INSERT INTO items_applications (applicationid,itemid,itemappid) VALUES ('973','27679','13296')".' in /usr/local/www/zabbix3/include/classes/db/DB.php:81 While playing around in CHttpTestManager.php I think I have found what the problem is. In update() function the $deleteStepItemIds is collected and deleted at the end of this function. But this is too late, because when createStepsReal() function is invoked, inside it searches current items and uses the ones that are going to be deleted. I have solved the problem for me by moving the deletion code before invoking createStepsReal() as in the attached diff. |
Comments |
Comment by Kim Jongkwon [ 2016 Jul 13 ] |
This SQL ERROR occurs when using the parameters below.
|
Comment by Kim Jongkwon [ 2016 Jul 13 ] |
NOTE: ・If you use same data without "applicationid" & repeat... |
Comment by vitalijs.cemeris (Inactive) [ 2016 Jul 15 ] |
Main issue fixed in the development branch svn://svn.zabbix.com/branches/dev/ZBX-10842 |
Comment by vitalijs.cemeris (Inactive) [ 2016 Jul 15 ] |
(1) Second case described in oleg.egorov CLOSED |
Comment by vitalijs.cemeris (Inactive) [ 2016 Jul 19 ] |
(2) Third case described in RESOLVED in r61094, r61097, r61218 oleg.egorov CLOSED |
Comment by vitalijs.cemeris (Inactive) [ 2016 Jul 29 ] |
(3) Strings deleted:
oleg.egorov CLOSED |
Comment by Oleg Egorov (Inactive) [ 2016 Sep 16 ] |
(4) Undefined index $httpTests = API::HttpTest()->update(array( 'httptestid' => 80, 'name' => 'test4', 'hostid' => 10114, 'status' => 0, 'delay' => 60, 'steps' => array(array( 'name' => 'test', 'url' => 'http://mycompany.com', 'status_codes' => 200, 'no' => 1 )) ));
vitalijs.cemeris RESOLVED in r62670 oleg.egorov CLOSED |
Comment by Oleg Egorov (Inactive) [ 2016 Sep 16 ] |
(5) Coding style if (isset($httpTest['steps'])) { vitalijs.cemeris RESOLVED in r62674 oleg.egorov CLOSED |
Comment by Oleg Egorov (Inactive) [ 2016 Sep 16 ] |
(6) HttpTest with application $httpTests = API::HttpTest()->create(array( 'httptestid' => 80, 'name' => 'test6', 'hostid' => 10114, 'status' => 0, 'delay' => 60, 'applicationid' => 543, 'steps' => array(array( 'name' => 'test', 'url' => 'http://mycompany.com', 'status_codes' => 200, 'no' => 1 )) ));
HttpTest create with 'httptestid'. In clean 2.2 this issue not exist No SQL error, but issue still exist vitalijs.cemeris RESOLVED in r62616, r62631, r62667 oleg.egorov CLOSED |
Comment by Oleg Egorov (Inactive) [ 2016 Sep 23 ] |
(7) [A] Please remove unnecessary comments. vitalijs.cemeris RESOLVED in r62734 oleg.egorov CLOSED |
Comment by Oleg Egorov (Inactive) [ 2016 Oct 05 ] |
TESTED |
Comment by vitalijs.cemeris (Inactive) [ 2016 Oct 13 ] |
Fixed in:
|
Comment by vitalijs.cemeris (Inactive) [ 2016 Oct 14 ] |
(8) [D] API documentation:
Changes in 2.2, Changes in 3.0, Changes in 3.2 RESOLVED martins-v Moved to appropriate sections - 2.2.16, 3.0.6, 3.2.2. CLOSED iivs "mehtod" REOPENED martins-v RESOLVED iivs The name of the API method is before the sentence. Why need to repeat it in the end again? martins-v Removed. RESOLVED iivs Ok, looks better. CLOSED |