8

For most of our clients we've got a basic ant script that does a test deploy every night to make sure all the tests pass.

Occassionally, we'll get a REQUEST_RUNNING_TOO_LONG error. What's strange is that the time stamps it print don't seem like something that would generate an error. Take the output below for example, the deployment had only been running for 11 minutes (they typically take about an hour), and the test it had to stop had only been processing for 1s. What gives? Any idea what's causing this error?

BUILD FAILED
/home/ec2-user/ant/auto_repos/example/build.xml:39: Failed to process the request successfully. Cause(UNKNOWN_EXCEPTION): Running test: Example, time spent on that test: 1236ms,  total time spent running tests: 646005ms. Error: REQUEST_RUNNING_TOO_LONG: Your request was running for too long, and has been stopped.

Total time: 11 minutes 8 seconds

Additionally, with winter '16 these is happening pretty frequently, probably around 15% of test runs. With the automated test run it's not such a big deal, but waiting an hour doing a deployment to get this error is pretty frustrating (happened three times in a row last night).

Does anyone have info on why this is happening? Is this just a fact of life of the platform?

  • 1
    no answer her yet either but someone else appears to be having the same issue developer.salesforce.com/forums/?id=906F00000005IflIAE not sure if you've opened a support case or not yet. – Jenny B Nov 6 '15 at 3:05
  • yeah, seems like the prevalence increased greatly with winter '16, i swear there was a known issues about performance being degraded with trace flags enabled resulting in more cpu limit and request running too long errors, but not having any luck finding a link today – Ralph Callaway Nov 10 '15 at 0:01
3
+100

Each Apex transaction has a Maximum execution time of 10 minutes which is distinct from the Maximum CPU time per transaction on the Salesforce servers of 10,000 milliseconds for synchronous code and 60,000 milliseconds for asynchronous code. The 10 minute time limit exists to help prevent a thread from "hogging" server resources because the of the below limitation on what's counted towards CPU usage limits:

Operations that don’t consume application server CPU time aren’t counted toward CPU time. For example, the portion of execution time spent in the database for DML, SOQL, and SOSL isn’t counted, nor is waiting time for Apex callouts.

Note that the Maximum SOQL query run time before Salesforce cancels the transaction is 120 seconds.

One other possibility that could be impacting your tests is related to batch classes. Although only a single batch of 200 records are tested in a batch class, the production limits would still seem to apply. There are limits on the number of attempts and the time it takes to run the query for the batch class as follows: 15 attempts to process the query are allowed with a two minute limit on the time to process the query. There's a 5 min limit to process 100 records and a 10 min limit to process a batch before it's returned into the queue for later reprocessing. If it's returned more than 10 times, the batch is marked as failed. Max query retrieval size is 1Gb.

I wouldn't normally expect to see any of the above happening in a test class, but if a server is running especially slow, any of the above possibilities for either a batch or the execution of long transaction would seem possible. More than anything, it sounds as though the limit on the Maximum execution time of 10 minutes per transaction is what's causing your problem.

See the documentation for more on Per-Transaction Apex Limits.

  • Interesting post, does seem like some of these concepts could be related, and salesforce is just not applying them correctly to tests, looks like further down and they have a single line applying to tests Limits apply individually to each testMethod.. What's strange is the error message says the test it stopped on was running for just a little over 1s, and deployments almost always go over 10 minutes. My best guess is that with parallel test processing the error message just isn't reporting the correct test method, and there is in fact a test that's running too long, I just don't know which – Ralph Callaway Nov 9 '15 at 23:58
  • 1
    As you know, the way test methods are handled changed with W16. It could very well be that the latest round of changes introduced some kind of anomaly that is causing the problems you're seeing. The line coverage calc method also changed with SU15. Parallel execution is the default which could be problematic for some methods due to contention. See developer.salesforce.com/docs/atlas.en-us.198.0.apexcode.meta/…. Even docs suggest that "run all tests" can be problematic. Running tests using ApexTestQueueItem is in beta - see docs 4 pages earlier. – crmprogdev Nov 10 '15 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.