jamessimone / apex-rollup

Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.
MIT License
210 stars 30 forks source link

Attempt to de-reference a null object when refreshing from flow #485

Closed segdan closed 11 months ago

segdan commented 1 year ago

Hi,

I'm facing a strange issue when rolling up in a refresh context from a flow.

11:09:56.211 (2332211837)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object

Class.RollupCalculator.DecimalRollupCalculator.handleSumOrCount: line 589, column 1 Class.RollupCalculator.performRollup: line 205, column 1 Class.RollupAsyncProcessor.getCalculator: line 1347, column 1 Class.RollupAsyncProcessor.getUpdatedLookupItemsByRollup: line 1250, column 1 Class.RollupAsyncProcessor.process: line 694, column 1 Class.RollupAsyncProcessor.performWork: line 350, column 1 Class.RollupAsyncProcessor.QueueableProcessor.execute: line 457, column 1

I checked the log file but I'm unable to determine which one is the null object referred, and apparently this error is blocking all the rollups from beign calculated. I'm on version 1.5.83. Please find the whole log file attached and let me know if anything else is needed to debug this problem. Thanks

07L0D00000Gwj7lUAB.log

segdan commented 1 year ago

found the problem, one of the metadata records had a string default value instead of a decimal one. Now I have a different problem: when the rollup refresh is triggered by the flow, the rollups are not updated 90% of the times (strangely sometimes they are updated but I couldn't understand why), but if I use the recalculate rollups button it works everytime

jamessimone commented 1 year ago

Hey @segdan, happy to try to help. Prior to being able to speculate on what the issue is, would you be able to update the Org Default Rollup Control custom metadata record to enable Is Rollup Logging Enabled and generate a log file to upload here? The log should show what's going on. Typically, there will be three logs generated when you update a record with Apex rollup - one with Origin of Aura, which is the sync part of the process. Then there's a QueueableHandler / blank Origin log - that's the one that probably has the info we need to examine. There's another log with the same origin as the second one; this is the RollupFinalizer and you don't need to include it. The aura and first of the two queueable logs would be very helpful though!

segdan commented 1 year ago

Hi @jamessimone , thanks for the quick feedback. Here are the two files, let me know if you need anything else. These logs were generated in one of the attempts where the rollups didn't update. If this can help, I'm specifically checking the Total_ARR_Override__c field on OpportunityLineItem, which should have been updated to 211000, and instead has the old value of 263000. I guess also the other rollups are not updated, but this one for sure is not. 07L0D00000GwjnPUAR.log 07L0D00000GwknTUAR.log

jamessimone commented 1 year ago

Thank you! I will have a look.

jamessimone commented 11 months ago

@segdan I apologize for the long delay in response - the past few weeks have been a bit busier than expected. I finally had the chance to review the logs you sent over, and now I have more questions:

While there shouldn't be "update collisions" between separate fields on the parent object due to the rollups starting from two different types, it's hard to say for certain based on the existing logs (as they only contain the "setup" part of the rollups; the async portion happens in a separate log). I'm happy to continue trying to help (hopefully this time with much less in the way of delay). Let's get this figured out together!

jamessimone commented 11 months ago

Closing for now - please feel free to re-open with more information if this issue is still occurring!