One of our client is seeing this issue in their production org. Following is the line where this issue is occuring :

ID batchId = Database.executeBatch(MainBatch);

This line is throwing

System.StringException : Invalid Id 000000000000000

There is a scheduler which periodically executes this batch and scheduler is running by a System Admin user, so it has all the permissions.

Has anybody ever faced such issue? And is their any solution for this? In this case we do not have any use of batchId variable so I will definitely remove that which I think would fix the issue but if anyone has more information, please share.

  • 3
    The Database.executeBatch API doesn't actually execute the batch but rather it serializes the given batchable implementation into the database, adding it to the queue for batch processing asynchronously after the current transaction. As such, if this truly is the line causing the exception (seems unlikely), I would suggest there must be a serialization issue. Please edit the question to add the batch declaration and all its attributes, along with the constructor and any other methods called on the MainBatch variable prior to calling Database.executeBatch.
    – Phil W
    Apr 29, 2021 at 7:05
  • Is this an intermittent issue or happens every time the batch runs?
    – Swetha
    Apr 29, 2021 at 7:53
  • @PhilW This is exactly the line which is returned in the exception email. Do you think any other issue in the batch code could cause this issue?
    – Mr.Frodo
    Apr 29, 2021 at 8:19
  • 1
    @Swetha This is an intermittent issue.
    – Mr.Frodo
    Apr 29, 2021 at 8:21

1 Answer 1


This error seems to occur when a batch job is moved to the flex queue. When it enters the flex queue, it tries to acquire a flex queue token. If it fails to receive the token, this error is thrown and the batch job is aborted.

Also documented in article:

"If the executeBatch call fails to acquire an Apex flex queue lock, the call returns an empty ID, "000000000000000", instead of throwing an exception."

The current way to avoid a situation like this is to handle the failed scenario as mentioned in the known issue

Consider modifying your code to verify the return value from Database.executeBatch() method.

Database.executeBatch(new BatchClass(), 1);

String jobID = Database.executeBatch(new BatchClass(), 1);
if( jobID. startsWith('707') ){ //707xxxxxxxxxxxx should be returned when Batch job starts properly.
 // Success case
} else {
 // Failed case
  • 2
    Thanks for your answer with the known issue link. It is really helpful.
    – Mr.Frodo
    Apr 29, 2021 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.