function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Phil WPhil W 

Does Salesforce rollback a transaction when CPU limits are exceeded?

We have some CPU intensive processing we have to apply, and as part of this we have to perform a temporary DB upsert of some data (so we know that formulae, triggers and workflows are evaluated for the temporary data as we need to be able to leverage the results of that extra processing). We deal with this by setting a DB save point and, after evalulation, we restore to that save point.

Now, one of our customers has too much processing in some workflows/custom triggers and this is pushing us over the CPU limits (we have a way to avoid this by splitting the data domain into pieces, which we are doing). However, the observed behaviour was that our temporary updates to the DB were actually being persisted after the CPU limits were exceeded.

We rather expected that exceeding CPU limits would roll back our updates, but the customer appears to see the temporary data being persisted. Thus the question in the title of this posting: does Salesforce rollback a transaction when CPU limits are exceeded, or does it commit the transaction instead? If the latter, is there a way to control this behaviour?
Phil WPhil W
Anyone got any insight on this one?
Phil WPhil W
Anyone?
Nicolas FrancoNicolas Franco
Yes. It actually rollbacks the trasaction. Source: https://help.salesforce.com/s/articleView?id=000389177&type=1