Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-10842

httptest.update fails when updating steps without httpstepid

    Details

      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
      /4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727) S","authentication":"0","delay":"300","http_password":"","http_user":"","macros":"","status":"0","steps":[

      {"name":"step1","url":"http:\\/\\/test.cz","required":"","status_codes":"200","no":1}

      ]},"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
      Stack trace:
      #0 /usr/local/www/zabbix3/include/classes/db/DB.php(441): DB::exception(1, 'SQL statement e...')
      #1 /usr/local/www/zabbix3/include/classes/api/managers/CHttpTestManager.php(874): DB::insert('items_applicati...', Array)
      #2 /usr/local/www/zabbix3/include/classes/api/managers/CHttpTestManager.php(219): CHttpTestManager->createStepsReal(Array, Array)
      #3 /usr/local/www/zabbix3/include/classes/api/managers/CHttpTestManager.php(603): CHttpTestManager->update(Array)
      #4 /usr/local/www/zabbix3/include/classes/api/managers/CHttpTestManager.php(58): CHttpTestManager->save(Array)
      #5 /usr/local/www/zabbix3/include/classes/api/services/CHttpTest.php(328): CHttpTestManager->persist(Array)
      #6 [internal function]: CHttpTest->update(Array)

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                majo Marián Černý
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: