Rest calls not reaching web services

Since beginning to use SuiteCRM we have run into an issue with the web services. I’m hoping someone has experienced the same issue and might have insight on possible causes or fixes.

Summary of the issue:
Web service calls using rest v4_1 occasionally fail. This is more prominent when trying to do a set_relationship and set_document_revision. We have not observed this happening on any calls which pull information. Only calls that write.

Troubleshooting done
I have checked the logs both in suitecrm.log and sugarcrm.log and there are no errors at the time of the failures
I have verified that CPU and RAM have low usage
I have verified there is a lot of disc space on both my suiteCRM install and my MSQL database.
I added logging to the rest.php file to see calls coming in and what I have noticed is that the set_relationship calls arrive but fail somewhere after leaving that file. When it comes to failed set_document_revision the call never reaches this file.

Full description of the issue
We have an installation of SuiteCRM which contains around 40 custom modules. We had used SugarCRM 6.5 prior to moving to Suite and never ran into these
issues. Most of these modules are populated by data from online forms which use rest v4_1. Other modules such as leads are updated from a cron job on the same server as the install and also uses the same web services. We also run bulk uploads daily which upload from 300-1000 files and attach themselves to leads.
We have been noticing that randomly and without warning our calls fails as stated above. I’ve tried to loop the calls 4-5 times incase the call fails the first time but we are still running into unexplained failures. When it comes to our bulk uploads we set the relationship with the leads and then create the document revision. What we noticed here is that all the ones that have failed revisions had had the set_relationship attempt to run 2-4 times (and sometimes that even failed on attempt #4) but the record after works without issues. There has never been two records created on after the other that hasn’t worked. As an example using bulk uploads. Out of 200 being processed, 10-20 will have issues. I know it might seem like a low failure rate, however these are important documents and we get numerous complaints from different departments that deal with our company’s leads.

Have you checked if any workflows or logic hooks are running when those saves are being done, that could be interfering?

Sometimes it’s not intuitive, but some saves will trigger hooks, and then if you save inside a hook, it will recurse, etc.

We don’t use any workflows using the workflow module and our logic hooks are only used to send emails or set other fields in the same module. They don’t create relationships or touch document revisions. Our hooks also only run on before_save so it wouldn’t cause anything to recurse. We’ve been very careful not to call save on any before_save hooks.

I would still check those hooks, and try running tests with those disabled, just to see if there’s any interference. It could be SuiteCRM itself that is triggering unexpected saves.

Also, have you been checking php_errors.log or errors.log (whatever your web server log is called)? That’s where PHP errors appear, it’s never enough to just look at suitecrm.log.

Thank you for your reply.
I’ve tried removing the hooks and checked the logs. The failure rate has remained the same and there’s actually nothing in the php logs at those times.
We never have issues with the set entry. Could there be any reason the following pattern would happen?
I have noticed is that the set_relationship calls arrives to rest.php but fail somewhere after leaving that file. When it comes to failed set_document_revision the call never reaches this file.

And the logs, what do they have at that moment?

That’s the issue that is making it hard to debug. There is nothing at that time. Nothing in our PHP log and nothing in the Suite/Sugar log files. I know the logs work because I get the logs when I make a mistake when developing a custom view or when a report runs out of allowed memory.

Maybe you can add some extra log commands to SuiteCRM, until you get a closer idea of what is happening. Also consider installing XDEBUG and goign through this with an IDE like Eclipse, PHP Storm, or similar.