2

Currently we are using informatica data loader which loads a bunch of contacts in salesforce using bulk api. The underlying trigger on contact would create account, contact and other related objects. When we use the bulk api on the data load , we get apex cpu time limit exceeded. This happens only if we use the bulk api and if we use regular upload, it works. Is there anything which we need to do for bulk api or how can we get past the cputime limit exceeded error?

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:EnrollmentrxRx.ContactCustomerPortal: execution of BeforeUpdate caused by: System.LimitException: Apex CPU time limit exceeded Class.ApplicationTriggerHandler.applicationAfter: line 116, column 1 Class.ApplicationTriggerHandler.afterUpdate: line 51, column 1 Class.TriggerFactory.execute: line 71, column 1 Class.TriggerFactory.createHandler: line 32, column 1 Trigger.ApplicationTrigger: line 13, column 1:—

  • Review your code and optimize it. May not be the answer you want to hear but it may be what is required – Eric Oct 20 '15 at 4:07
  • Remove the triggers and write Batch Apex to run after the import on the Bulk API. – TimChadwick Oct 20 '15 at 8:10
2

There is no specific setting that will increase CPU time for bulk api.

What is happening is that when you schedule data load through bulk it put system under stress and it is not able to finish the given task in appropriate time and so throws error Apex CPU time limit exceeded.

To avoid CPU limit you need to optimize your code. Here are few tips:

  1. Check the trigger execution and note the required time.
  2. With the help of developer console you can figure out where CPU time is spent and then target the area which most CPU costly.
  3. try and optimize those costly code blocks
  4. Note for optimization of trigger you can use anomalous block to fire trigger

Helpful link:

  • I'd add to this reducing the size of your bulk load by splitting it into chunks where the trigger and other processing time will not cause you to exceed the limits. – Phil W Oct 1 '18 at 21:05
1

One option is to run you bulk job in serial mode. There is a setting for the bulk jobs called Concurrency Mode If you set it to be Parallel It will then process the batches one by one, which is the same as using soap api. The processing time will increase as well.

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.