-
Notifications
You must be signed in to change notification settings - Fork 27
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
Incorrect rollup calculations when child records are inserted in separate transactions at the same time #579
Comments
@puneetagarwal2971 what is your Max Parent Rows Updated At Once value and is that lower than your Batch Chunk Size? The parent updates shouldn't be happening in a separate queueable unless that condition is true, and if they're updated at the same time as each batch chunk is committed the proper values should be applied |
@jamessimone In my scenario, I'm inserting 100 child records all linked to one single parent. Now, the rollup count result should be 100 but instead, it is a lot lesser. The same happens if I delete all the related child records. Let's say we have Rollup Count = 100, and we delete all 100 child records in batch size = 1. |
Have you tried setting the Is Full Record Set flag on your rollup metadata? |
Yes, thanks @jamessimone! The numbers the accurate now with above query-based rollup setting. But for some records, I still see the error: |
With a batch size that small, I could see row locks being intermittent - reason being that children associated with the same parent sent through will be contending for the update at the same time. As you said, a schedule-based rollup may be more appropriate if you can't increase your batch size for other reasons. |
Recreate issue:
Bulk Insert child records with a smaller batch size(let's say 1) and use multiple threads, the rollup calculations get messed up.
This is because the parent record update is performed in an Async Queueable context unlike the parent record being locked for sometime in native salesforce roll-ups.
Eventually, each thread tries to update the parent record rollup field parallelly but does not wait for either.
E.g. Initial Count() - 0
Try inserting 2 records parallelly, then both try to update Count to 1 instead of 1+1 = 2.
Use Case: We have integrations that are pushing records in smaller chunks in separate transactions.
The text was updated successfully, but these errors were encountered: