apex-rollup icon indicating copy to clipboard operation
apex-rollup copied to clipboard

Inconsistent Sum Behaviour On CMDT Grandparent Full Recalculate rollup

Open jaredcloudyknights opened this issue 1 year ago • 8 comments

Hi,

I've noticed some inconsistent behaviour regarding the Grandparent rollup when using the Full Recalculate button or when an update is triggered by a batch job. The rollup to the parent works fine but the grandparent will sometimes double or half the value that should be there. Interestingly, re-running the recalculate will often resolve the incorrect amounts (but sometimes cause other records to become incorrect).

For context in the loom/screenshots: Revenue_Booked__c records are created by a batch job which then triggers two rollups defined by two CMDT to two records, a parent (Credit_Line__c) & a grandparent (Loan__c). This behaviour can also be intermittently observed on using the full batch recalculate via the "Recalculate Rollup" page. I've checked and all objects have the rollup trigger setup correctly (otherwise nothing would work I imagine).

Loom Explainer here

Details about the two CMDT records in question:

  1. Revenue_Booked__c -> Credit_Line__c (Parent) image
  2. Revenue_Booked__c -> Loan__c (Grandparent) image

I've also got Nebula Logger installed in my test org, but can't make heads or tails of what the cause may be & I can regularly replicate the issue.

Version number: 1.6.32 image

Let me know if any more detail is required. Also fully recognise that it could be something to do with how my rollups are set up. 😄

EDIT: I've been trying to do my own debugging and playing around with batch sizes. I've noted that changing the batch chunk size causes the issue to amplify/exacerbate wildly. Batch Settings image

Cross-Check Report results (over 50% of records are now affected) image

jaredcloudyknights avatar Aug 15 '24 06:08 jaredcloudyknights

Hello, and thanks for submitting this! I will take a look, but I won't be able to begin investigating till next week. Just wanted to keep you informed as to the timeline; I'll follow up here next week with questions.

jamessimone avatar Aug 15 '24 12:08 jamessimone

No worries, thanks @jamessimone, completely understand. And thanks for all your hard work on this!

jaredcloudyknights avatar Aug 15 '24 23:08 jaredcloudyknights

@jaredcloudyknights apologies for the delay in response - I've finally had the chance to start looking into this issue and thanks to the wonderful video you recorded and the details you've shared here, I believe I've pinpointed the problem. I'm going to do my best to get the fix out with the next version, which I hope to release today

jamessimone avatar Aug 22 '24 13:08 jamessimone

@jaredcloudyknights if you're able to test on the new version, let me know! I made some changes that may help.

jamessimone avatar Aug 28 '24 12:08 jamessimone

@jamessimone sorry just had a chance to update the package and retest. Unfortunately, it looks to still be occurring. I've recorded another Loom here stepping through the reproduction of the issue.

image

jaredcloudyknights avatar Aug 29 '24 04:08 jaredcloudyknights

Not to worry. I am continuing to look into this - apologies that it's been slow going

jamessimone avatar Aug 30 '24 17:08 jamessimone

It's my belief that this issue and #615 are related, and I'm continuing to work on a resolution for both

jamessimone avatar Sep 07 '24 15:09 jamessimone

Thanks @jamessimone for the update

jaredcloudyknights avatar Sep 08 '24 22:09 jaredcloudyknights