Intermittent API error -32500 (SQL failed) due to FK constraint on permission table during parallel provisioning

XMLWordPrintable

    • Type: Incident report
    • Resolution: Unresolved
    • Priority: Major
    • None
    • Affects Version/s: 7.0.22
    • Component/s: API (A)
    • None

      We are experiencing intermittent -32500 (SQL failed) errors via the API when running parallel provisioning scripts and JIT AD syncing. Currently, this issue is impacting a client's environment with over 1,000 users.

      While initially thought to be exclusively related to host.create, we observed this happening with user provisioning/updates as well ("cannot add/update user").

      The issue seems to be a race condition highly similar to the logic discussed in ZBX-27448. When multiple parallel processes attempt to create entities with uniquely new host-group/user-group combinations, the processes attempt to "reserve" the same future IDs for the new group-set's hash. This results in a clash during insertBatch() within createHgSets(), ultimately failing when inserting related records into the permission table because the parent hgset record hasn't been successfully committed yet.

      The API intermittently returns a -32500 (SQL failed) error.

      Looking at the frontend debug logs (API response debug), the following foreign key constraint failure is exposed:

      cannot add or update a child row: a foreign key constraint fails (`zabbix`.`permission`, CONSTRAINT `c_permission_2` FOREIGN KEY (`hgsetid`) REFERENCES `hgset` (`hgsetid`) ON DELETE CASCADE)

            Assignee:
            Zabbix Support Team
            Reporter:
            Lucas Frade
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: