"SELECT ~ FOR UPDATE" query need to exception handling - like 'DBSELECT_FOR_UPDATE_ERROR'
Unfortunately, 'deadlock' error can happen ids table update via ZABBIX API with use multiple threads execute in mysql.
The problem in this 'SELECT ~ FOR UPDATE" query cases,
When a transaction rollback occurs due to a deadlock or lock wait timeout error, I didn't received any 'error' response from API.
We have observed this error using 'trigger.update'.
- Query in transactions >
SELECT nextid FROM ids WHERE nodeid=0 AND table_name='functions' AND field_name='functionid' FOR UPDATE
- SQL Error>
"Deadlock found when trying to get lock; try restarting transaction"
In Database : TRANSCTIONS_FAILED -> rollback
API Response : triggerid (ERROR does not return)
Source: frontends/php/include/classes/db/DB.php - reserveIds()
Related issue:
ZBX-11062 - API - Deadlock occurs when multiple API call processes with MySQL