function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
S_2013S_2013 

Apex Debug Log duration shows max int value

Hi,

I have a strange scenario that one of my Schedulable Apex jobs starts and finishes in less than 6 minutes, but still, on Monitoring > Debug Logs i see the Duration printed every time as 2,147,483,647 ms, which is the max possible integer value.

 

The job duration cannot be more than 5 * 60 * 1000 = 300000 ms but everytime i run the ob it prints exactly the same output. I searched in Apex workbooks but couldn't find anything relevant... can anyone please throw some light if possible?

 

P.S. My Schedulable job DOES spawn a Batchable job with a preset batch size. (but the entire duration of the Batchable + Schedulable jobs is < 6 minutes)

 

Thanks in advance

S_2013

Best Answer chosen by Admin (Salesforce Developers) 
Vinita_SFDCVinita_SFDC

Hello,

 

The duration in the apex log object displayed in the debug log includes the time from the creation of the log, which happens early after the apex context is created, but potentially before apex class loading, which has to happen before we start executing any apex. Also the
end time is recorded after the file is written.

 

Hope this helps!

All Answers

Vinita_SFDCVinita_SFDC

Hello,

 

The duration in the apex log object displayed in the debug log includes the time from the creation of the log, which happens early after the apex context is created, but potentially before apex class loading, which has to happen before we start executing any apex. Also the
end time is recorded after the file is written.

 

Hope this helps!

This was selected as the best answer
S_2013S_2013

Vinita,

 

Thanks a lot definitely i get a better idea of whats happening now ...

but one ques: What is the apex context? I tried searching but could not find anything relevant...

The log duration for controller classes are always correct so I guess my class being the Schedulable class is causing the difference...

But in no SFDC doc could I find anything written about when a Schedulable class is loaded...

 

Regards

S_2013

Vinita_SFDCVinita_SFDC

Hello,

Apex context, also referred as execution context, has two characteristics:

> It defines the scope and lifetime of static variables.

>It defines the context for those governor limits that are reset between execution context

The apex code initiates whenever there is a code execution, which includes:

>A database trigger: Triggers can occur on insertion, update, deletion or undeletion of many standard Salesforce objects and all custom objects.

>Future call: Future calls can be requested from Apex code. They run with extended limits.

>Scheduled Apex: You can implement an Apex class that can be called by the system on a scheduled basis. Batch Apex: You can implement a class designed to process large numbers of database records.

>Web service: You can implement a class that can be accessed via SOAP or REST from an external site or from JavaScript on a web page.

>VisualForce: Your VisualForce pages can execute Apex code in VisualForce controllers to retrieve or set page properties or execute methods.

>Global Apex: You can expose a global method that can be called from other Apex class.
 

For a better understanding please refer below link: http://kperisetla.blogspot.in/2012/07/apex-execution-context-in-forcecom.html

Regarding schedulable class you are correct, scheduled apex is asynchronous process. Salesforce schedules the class for execution at the specified time. Actual execution may be delayed based on service availability.

Refer: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm