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

XMLWordPrintable

    • S26-W10/11, S26-W12/13, S26-W14/15, S26-W16/17, S26-W18/19, S26-W20/21, S26-W22/23, S26-W24/25
    • 5
    • 1

      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)

        1. delete.sh
          0.6 kB
        2. insert.sh
          6 kB
        3. select.sh
          0.4 kB
        4. X 1.png
          X 1.png
          200 kB

            Assignee:
            Nikita Gogolevs
            Reporter:
            Lucas Frade
            Team C
            Votes:
            1 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 50h Original Estimate - 50h
                50h
                Remaining:
                Time Spent - 292h 10m Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - 292h 10m Remaining Estimate - 1h
                292h 10m