+ Start a Discussion
Rick_NookIndRick_NookInd 

Debug Log when there is an Apex error?

I've having trouble determining the combination of circumstances that are causing triggers cumulatively to exceed the 20 SOQL query governor limit.

 

I can't get a Debug Log for these because I can only request 20 debug logs at a time, and I do tens of thousands of transactions.  So I have no way of determining what combination of triggers and circumstances are causing the governor limit to be exceeded.  Furthermore, I can't even build my own debug log because database transactions and emails are rolled back when the governor limit is exceeded.

 

I have seventy some triggers on a dozen or so related objects.  A good portion of those potentially may need to make a SOQL query under certain circumstances.  A good portion may need to do a DML operation under certain circumstances.  They all work in batch, and if the circumstances don't seem to require the query or the DML I'm pretty good about not doing one to stay under the limit.

 

They are triggered by each of tens of thousands of transactions a day.  Maybe one or two of those exceed the governor limit even with a batch size of 1 for a certain object.  Many do with a batch size of 200.

 

I can log what data is being upserted, but I don't know necessarily know the exact state of the database in other objects or what triggers were fired because of these related records.  For example, I can know I posted a primary CSR to a quote, but I don't know that the primary CSR is changed, that it doesn't match the opportunity owner, or that the related order was priorly given credit to someone else.

 

Ideas?

gv007gv007

If you are not able to see the  problematic query in  DBL ,try to get it from the salesforce user email. If you got any limitation like it automatically fire a exceptions mail to user have the logs.

Rick_NookIndRick_NookInd

Gopi,

Not sure what you are suggesting.  I have no DBL.  That is the problem.

 

All I have is (via email):

 

Apex script unhandled trigger exception by user/organization: xxx/yyy

Opportunity_Ownership_Trigger_Before: execution of BeforeUpdate

caused by: System.Exception: Too many SOQL queries: 21

Trigger.Opportunity_Ownership_Trigger_Before: line 14, column 25

 

and returned from the Apex Data Loader (with the data):

"Opportunity_Ownership_Trigger_Before: execution of BeforeUpdate caused by: System.Exception: Too many SOQL queries: 21 Trigger.Opportunity_Ownership_Trigger_Before: line 14, column 25"

 

This tells me the 21st query, but gives me no hint what the prior 20 queries were.

AlexPHPAlexPHP

The debug log may not show all the queries that executed, but it will show you from the point of entry, what triggers/classes were called and how many SOQL queries each one takes up.

 

You will see the cumulative SOQL query count increase with each trigger/class that it goes through, and you should be able to figure out how it reached and broke the 20 limit.

gv007gv007

Rick,

          test repeatedly the same functionality you get extract query in the mail i got so many times like that.After looking yours previous if found anything let you know.

 

Please check "Opportunity_Ownership_Trigger_Before " trigger you can find the query.

 

I think in this trigger the query is not excution and skiping the code.How many lines the triggers is. 

 

Thanks

Gopi