/
TAP-902 CPU Time limit Analysis and Simulation

Attention: Confluence is not suitable for the storage of highly confidential data. Please ensure that any data classified as Highly Protected is stored using a more secure platform.
If you have any questions, please refer to the University's data classification guide or contact ict.askcyber@sydney.edu.au

TAP-902 CPU Time limit Analysis and Simulation

Items Fixed by Flow Optimization

  • Too many SOQL queries: 201 Flow "Populate Chart of Accounts in Transaction"

  • Batch closing error - We can't save this record because the “Create a link to a Third Party Pledge” process failed (DUPLICATE_VALUE: Maximum number of duplicate updates in one batch (12 allowed). )

Defect

  • CPU Time Limit in TAPSS-891

  • What is a CPU timeout error? Salesforce limits CPU usage to 10 seconds for synchronous transactions and 60 seconds for asynchronous transactions. Seeing the error “Apex CPU time limit exceeded” means your transaction is taking too long and can't be completed. Salesforce platform imposes a CPU usage governor limit to any given execution context, which is approximately 10 seconds. It means that Apex Code, declarative tools or a combination in a transaction, must not exceed a ~10-second limit. It is non-negotiable. This means we cannot increase the 10-second threshold by tweaking settings, buying more allocations from Salesforce or work around it by other means. It is an absolute hard limit.

891-002

  1. Payment batch creation

    1. Create a single batch record to create a payment across all created transactions under all the gift records in all the accounts from the intial batch created

    2. Confirm that the batch successfully closes

      1. confirm to see that all gift records' balances are 0 and transactions are created to act as payment to the intial transaction records created

    3. if the batch fails, Utility log log record will be created

Record Involved:

  • 1 Batch record

  • 11 Batch Items

  • 36 - 45 Transaction records per Batch Item

All steps should be executed successfully

FAIL

Batch 0076229 | Batch | Salesforce

20230529-2338 | UtilityLog | Salesforce

 

TECHNICAL FACTORS

  • Current Batch class by AQ (Managed packaged), code is hidden, thus, we cannot control the default size of the batch which is 10

  • There are Process Builder and Flow by AQ which design are also hidden:

    • Contact Default CAE Category

SIMULATIONS/REPLICATIONS DONE:

 

  1. MS tried to replicate the batch processing in SIT with lower batch size parameter of 1 in this record:

Batch 0076241 Record in SIT (10 batch items, with average of 35 to 45 Batch Items Transactions)

Ran this in execute anonymous in developer console:

String smartBatchId = 'a0ZBn000000Yx45MAC'; AQB.ProcessBatchItems aqSmartBatch = new AQB.ProcessBatchItems(smartBatchId); Database.executeBatch(aqSmartBatch, 1);

End Result: The batch record was closed successfully

2. MS also tested in RommelTest Sandbox with the latest version 24.0.1 - Batch 0075201 (10 batch items, with average of 35 to 45 Batch Items Transactions)

NOTE: The design of flows in RommelTest sandbox is the same with PROD (no optimization done yet)

1st Testing (Using the normal Close Batch button, the result is the same, we hit the CPU time limit issue

2nd Testing using the script with 1 batch size via execute anonymous in developer console, the Batch was closed successfully

3. Testing in UAT:

Unit Testing Variables:

  • 10 Batch Items of different accounts

  • 36 Transactions each Batch Item with payments, 2 of which no payments

Unit Testing Steps: Test User - Ana Simic

  1. Created Batch record with Batch items and transaction records comparable to original related Production record.

  2. Closed batch and received error on Utility Log (CPU limit not indicated on Details as UAT has different AQ package version).

  3. Close the batch record via execute anonymous in developer console

String smartBatchId = 'a0ZBm000000AdT7MAK'; AQB.ProcessBatchItems aqSmartBatch = new AQB.ProcessBatchItems(smartBatchId); Database.executeBatch(aqSmartBatch, 1);

4. Received a successful log.

5. Batch Record was closed successfully

CONCLUSION & RECOMMENDATION

The CPU time limit is a known error from Affinaquest as they don't have a configuration to adjust the Batch Size. This is still encountered during the test in RommelTest sandbox (Affinaquest version 24)

Completed Testing in SIT: SIT Testing Result

Open Items for Testing: TAP-1200/1222/1219 Issues Unit Testing

  • Bug in Join utility which blocks accounts being joined

Recommendation:

Do not deploy the optimization as part of May R2 Release since it’s not fully tested in SIT. MS team and @Yeng Sembrano will get more information from Affinaquest about how the batch process works on the background so we can do a Customized

Close Batch button that can be run whenever CPU time limit happens in PROD as an interim fix.

 

 

Related content

TAPSS-845/TAP-902: MS Team - To check the logic and any bad code practice for the list of flows mentioned and merge if required
TAPSS-845/TAP-902: MS Team - To check the logic and any bad code practice for the list of flows mentioned and merge if required
More like this
TAP Solution Slayers (TAPSS) - Team Space (to be archived)
TAP Solution Slayers (TAPSS) - Team Space (to be archived)
Read with this
TAP-1200/1222/1219 Issues Unit Testing
TAP-1200/1222/1219 Issues Unit Testing
More like this
Enhanced Domain: How to Test
Enhanced Domain: How to Test
Read with this
TAPSS - EOFY Issues (Receipting 06-Jul to 07-Jul-2023 Run)
TAPSS - EOFY Issues (Receipting 06-Jul to 07-Jul-2023 Run)
More like this
2023-11-23 AQ Consultation Session 7
2023-11-23 AQ Consultation Session 7
More like this