vt7.3 - vtws_create Inventory modules can return DATABASEQUERY_ERROR when the Inventory record has been created
We are seeing an intermittent error occurring when trying to create SalesOrder records via the Webservice.
- Occasionally we get a DATABASEQUERY_ERROR response. I have traced it back, and it appears to be because when attempting to create the LineItems one of them is failing due to the lineitem_id already existing and being a duplicate.
When creating the LineItems it goes through /include/Webservices/LineItem/VtigerLineItemOperation.php and specifically when the getNextId() function is called can occasionally return an ID value that has already been used - not sure how this is happening, but it does very intermittently, and is possibly linked to when the database /server is under high load... (lots of updates being made to SalesOrders at the same time?)
This function is an override of the /include/Webservices/VtigerActorOperation.php version of the getNextID function which seems to work differently? Not sure why the LineItem and Actor methods are different, but if I remove the LineItemOperation version of getNextID() then it all seems to work okay, and so far we havent seen the same issue that we were seeing before. Is there a reason why this function was over-ridden, when the base function works perfectly well?
- The second issue with this is that because the SalesOrder and the LineItems are created in separate database transactions, if the LineItems creation fails, the SalesOrder record is actually created, yet the Webservice response would indicate that it was not.
I don't know how to fix this currently, but would suggest that both the SalesOrder and LineItems are in the same transaction?