Slow queries always time out after ~2 minutes

Hey guys,

Iā€™ve been fighting this problem for months now. The issue is that slow queries (like ā€œGeocode Addressesā€, ā€œMass Updateā€, etc.) will always time out after about 2 minutes. I am presented with an ā€œError 500ā€ message, and rarely do even 100 records update properly.

Unfortunately, verbose logging does not give me anything useful. Neither does slow query logging. I just get your standard [debug] and [info] records.

I am running on IIS 7.5, with a MySQL database. I have tried increasing PHPā€™s ā€œmax_execution_timeā€, as well as various of the ā€œscript_limitā€ options in SuiteCRMā€™s config.php.

Any other ideas about what I can try? Iā€™m at a total loss at this point, and itā€™s becoming a problem that Mass Updates almost never finish completely.

Thank you in advance for any help.

Roquefort

Hi Roquefort,

What is your PHP/MySQL/server set up? Is this a hosted environment?

Thanks,

Will.

No sir, this is a self-hosted Windows environment:

Database
Windows Server 2012 R2
MySQL 5.6
Virtualized (Hyper-V)
8 CPU cores, 8GB memory
4 NICā€™s bonded on the hypervisor

Web Server
Windows Server 2012 R2
IIS 7.5, SSL-required
PHP 5.5.7 (I have tested ā€˜supportedā€™ versions and there is no perceivable difference in speed)
Virtualized (Hyper-V)
Wincache-enabled (after this problem already existed)
8 CPU cores, 8GB memory
4 NICā€™s bonded on the hypervisor

All of this said, I will note that SuiteCRM does in most situations seem quick and reliable. It is only these long queries that seem to get hung up.

For example, last week I was trying to change the ā€œContact Typeā€ of several thousand Contacts records. When I would try to do this with Mass Update, it was failing out with the ā€˜Error 500ā€™ after just 4 or 5 records! This would be after ~2 minutes of processing. I tried disabling Workflows completely - which helped a little. But it would still fail after 40 records or so.

I feel like there has got to be a PHP setting, or an IIS setting - or something - that is ā€˜killingā€™ the connection after a set amount of time. I just donā€™t know what that setting is, and I think that Iā€™ve already tried the usual suspects.

Thanks for the followup. Please let me know if there is anything else that you would have me try.

Regards,

Roquefort

So I set up ERROR-level logging again, and started creating test contacts. I noticed just this error firing:

09/30/14 01:52:17 [8260][5575ecc7-9b88-803d-0c3d-535dd8cf3c0c][FATAL] error loading relationship project_resource
09/30/14 01:57:30 [8260][5575ecc7-9b88-803d-0c3d-535dd8cf3c0c][ERROR] Unable to find relationship projects_quotes
09/30/14 01:57:30 [8260][5575ecc7-9b88-803d-0c3d-535dd8cf3c0c][FATAL] quotes for projects_quotes failed to load

Upon enabling the Project moduleā€™s menu item, and navigating to it, I see these errors while navigating around projects:

09/30/14 01:57:30 [8260][5575ecc7-9b88-803d-0c3d-535dd8cf3c0c][FATAL] error loading relationship quotes
09/30/14 01:57:31 [8260][5575ecc7-9b88-803d-0c3d-535dd8cf3c0c][ERROR] Unable to get proper side for link project_name_link
09/30/14 01:57:31 [8260][5575ecc7-9b88-803d-0c3d-535dd8cf3c0c][ERROR] Unable to get proper side for link project_name_link
09/30/14 01:57:31 [8260][5575ecc7-9b88-803d-0c3d-535dd8cf3c0c][ERROR] Unable to get proper side for link project_name_link
09/30/14 01:57:31 [8260][5575ecc7-9b88-803d-0c3d-535dd8cf3c0c][ERROR] Unable to get proper side for link project_name_link
09/30/14 01:58:05 [8260][5575ecc7-9b88-803d-0c3d-535dd8cf3c0c][FATAL] error loading relationship project_resource

Iā€™ve never once used the Projects module (in fact, it still had dummy data), so Iā€™m not sure what might have happened to it. I did try a quick repair, and a rebuild of the relationships. Does this info help at all?

Hi Roquefort,

These look like rogue relationships. Navigate to the project module and edit the vardefs.php file. If you can locate the project_resource and projects_quotes relationships, try to remove them and then run a Quick Repair & Rebuild and re-try.

Thanks,

Will.

I think this definitely worked for me, in part. Rather than removing any of these relationships, I dug into the Contacts moduleā€™s vardefs and found projects_contacts_resources was poorly formatted, for whatever reason. Fixing this formatting seems to have eliminated those error messages.

That said, it was still taking ~20 seconds to create a brand new Contact or Account record. By comparison, creating a new Lead takes about 3 seconds after clicking ā€œsaveā€.

Iā€™m doing WARN-level logging now, and I donā€™t see anything relevant. At DEBUG level, with slow-queries turned on, I started seeing numerous preprocess_on_save actions.

It turns out that those were related to Workflows. If I turn off Workflows for that module completely - it seems nice and fast again.

That said, I had built 8 workflows to automatically assign security groups to Contact records matching the specific states that we operate in. Iā€™d love to be able to do this still, if possible. Any idea how I can accomplish this without using Workflows (or in a more efficient way)? For what itā€™s worth, I have the same Workflows built on my Leads module, and it doesnā€™t seem to slow down the queries at all.

Okay, this is definitely a Workflow problem. Hereā€™s what I found:

  • I found a Workflow that probably had ā€œrepeated runsā€ enabled at some point. There were 23000 audit records for it.
  • This workflow takes a long time just to open. I canā€™t even delete it because the query times out.
  • If I disable the Workflow, and create a new copy of it, my ā€˜saveā€™ time is cut in half, to about 10 seconds.
  • Removing Workflows and duplicating them seems to be cutting the ā€˜saveā€™ time with every attempt.

So, Iā€™m not really sure why, but it seems like Workflows with long audit histories really slow down my system. Is expected behavior?

I found this thread as a result of a search for ā€œquotes for projects_quotes failed to loadā€ā€¦ and Willā€™s suggestion seems to have worked great for me.

I was/am not having the slow load times and queries.

Iā€™m using 7.1.4.1 on Azure, Bitnami install, currently have 8 cores, and 14GB memory to try and power through the importing, I really donā€™t think I need nearly this much power, and it seems something must not be right. I have memory_limit set to 2048M (also probably massive overkill) and PHP 5.4.35

In the project module vardefs.php file, I donā€™t have a project_resource. I did comment out projects_quotes relationship and did quick rebuild, but I can barely delete 100 contacts or tasks at a time.

I only had 1 workflow set up, which I have now set to inactive.

It seems that cranking up memory limit to 2048 allowed 100 records to be deleted at a time, but it seems I should be able to delete, or import for that matter 1000ā€™s of records in seconds with this server, it looks like itā€™s updating maybe 1 per second, if that. Any ideas?