Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apex CPU time limit exceeded when a batch is run #539

Closed
baobao917 opened this issue Nov 26, 2023 Discussed in #519 · 4 comments · Fixed by #540
Closed

Apex CPU time limit exceeded when a batch is run #539

baobao917 opened this issue Nov 26, 2023 Discussed in #519 · 4 comments · Fixed by #540

Comments

@baobao917
Copy link

I've created this issue b/c it is occurring more frequently now. Anytime I have to run an update on a batch of records of the rollup's child object, ApexRollup gets an Apex CPU time limit exceeded error. It occurs if it occurs in a scheduled flow or if I do a batch update of records directly. In my experience, I'm getting the error pretty consistently on any batches exceeding 70 (whereby the update operation isn't doing anything complicated...just populating a field value).

Discussed in #519

Originally posted by baobao917 October 8, 2023
I have a simple scheduled flow that runs that updates a collection of records. It is a very simple flow just updates one field on each of the records in the collection. It has previously worked without any issue.

These records are the child object in an Apex Rollup. Now that I've introduced the flow trigger on the child object, it has pushed the transaction time beyond the APEX CPU limit. I've tried to create the apex rollup flow trigger as asynchronous but it appears that it is not possible. Do you have any suggestions?

@jamessimone
Copy link
Owner

@baobao917 I've managed to reproduce this issue this morning. I have some ideas on how to streamline the process to make these updates from Flows more performant.

@jamessimone
Copy link
Owner

@baobao917 I'm nearly finished with the current round of optimizations, many of which I've pre-deployed to your sandbox. Hopefully I'll be able to wrap up this version today or tomorrow.

jamessimone added a commit that referenced this issue Nov 29, 2023
…ciency of where RollupCalcItemReplacer is called, by optimizing RollupRecursionItem constructor, by removing a logging statement from RollupEvaluator that was chewing through CPU time
jamessimone added a commit that referenced this issue Nov 30, 2023
* Fixes #539 by optimizing Flow update code paths by improving the efficiency of where RollupCalcItemReplacer is called, by optimizing RollupRecursionItem constructor, by removing a logging statement from RollupEvaluator that was chewing through CPU time
@baobao917
Copy link
Author

Thanks @jamessimone ! I saw v1.6.5 was related to this. Do you have an idea of what the batch size improvement should be now? The full 200? I saw that you noted that this was the low hanging fruit and that possible future enhancements possibly are coming as well....looking forward to it!

@jamessimone
Copy link
Owner

@baobao917 You can check out the Test - Apex Rollup Bulk Update James flow I made in your sandbox - that test was with ~100 records. I can expand the date range that flow is using to ensure higher record counts continue to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants