5

I noticed when creating a new dev org, and running my first batch job. I then query the AsyncApexJob table and there are 2 records instead of the expected 1.

There seems to be a default record in the table when the org is created. Anyone know the reason for this? Is this by design?

enter image description here

1 Answer 1

5

See What are the differences between the different possible jobs processed in the 'AsyncApexJob' object? for more information on jobs, but specifically they cover ApexToken:

An 'ApexToken' job is used for Flex Queue enabled organizations. From Winter '16 onwards, the flex queue is enabled by default for all organizations. If an Apex code block invokes Database.executeBatch(),instead of accepting the job directly into Salesforce's queueing system, an 'ApexToken' Job is submitted to the queue. For any batch job that a user submits, a token job is created internally. However, if the maximum number of queued batch jobs in the batch job queue has been reached, the new batch job is placed in a 'Holding' state in the flex queue.

'ApexToken' is our internal mechanism for managing system resources. When a token job gets picked up by the system for execution, it's an indication that the system can take in more jobs from the flex queue.

Note: Every organization has only limited number of 'ApexToken' jobs. This token mechanism allows organizations to submit more batch jobs (maximum is a 100), however only some of them could be running in parallel on the Salesforce platform.

Basically, the system generates these jobs periodically so that the runtime knows that more jobs can be accepted. This is expected, normal behavior.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .