I am an ISV provider and our managed package is experiencing this error in a batch job in a subscriber org. I cannot find any information on what it means. Oddly, debug logs on this error do not yield a stack trace, nor do they even surface which line of code is throwing the error. Though, if it is based on a SOQL query in our own code it could be inferred that it's this one, since this is the next query to execute after the debug information provided:

[SELECT Id, WhoId, CreatedDate FROM Event WHERE WhoId IN :whoIds AND IsDeleted = false ORDER BY CreatedDate ALL ROWS]

Note that whoIds is a Set of Ids.

However, I'm not even sure the error refers to an issue with an SOQL query per se, as the error is so non-descript that I'm wondering if it could be referring to something deeper than our own code. Plus we can't see why such a simple query could cause an error anyway.

Interestingly, this batch jobs also behaves very oddly in this org, in a manner we've never seen before, as the number of total batches per run actually steadily increases through its execution, which doesn't make sense. It starts on the correct number based on our calculations, but as batches execute total batches steadily increases throughout. This defies all understanding of how a query locator ought to work, let alone the number is no longer accurate after its first increase.

Also of interest, on the particular batch that fails with this error (which is only one of them among many), the status of the debug log is "Truncated", but there is no error message present - it can only be seen when I click into the log with the "Truncated" status. Interestingly this has its own category as far as the logs go.

Lastly, if I increase the batch size, more of the batches will fail with this error, so load does seem to play a factor.

Seems something very odd is afoot here. Any help is appreciated!

  • 2
    Does WhoId contain null? If you're querying only not-deleted records, why are you using ALL ROWS? Is there a WhoId that happens to have a ton of events attached to them? Does the user running the batch have View All Data? What's the OWD (Org-Wide Defaults) for the objects attached to these Event records? How many WhoIds are we even talking about? How many estimated Event records are in the client's org? While I couldn't find anything about this error, my guess is that the query is simply consuming too many resources. You might need Support/R&D to take a look. Do you get a GACK number?
    – sfdcfox
    May 20, 2022 at 15:53
  • No null IDs - there are 50 in total (leads and contacts). ALL ROWS was used to include archived events - however we've actually removed that as a test measure and the error continues without it. The query itself only yields 66 returned events. The context user does not have view all data, but contact and lead are both public read/write. There are a total of 39k events in the org Note that on the debug log list view, this isn't even reported as an inline error interestingly. Status of the log simply says Truncated with no status details.. Where would I see a GACK number? May 20, 2022 at 19:17
  • @sfdcfox wanted to make sure you saw my responses. Thanks! Side note: I do have a case in with SF support, though they've been slow to respond so far. May 23, 2022 at 15:45

1 Answer 1


I was able to resolve this with the help of Salesforce support. Turns out it wasn't the query I thought, it was the one before:

SELECT Id, ToIds, MessageDate, (SELECT Id, RelationId FROM EmailMessageRelations WHERE RelationId IN :whoIds) FROM EmailMessage WHERE Id IN (SELECT EmailMessageId FROM EmailMessageRelation WHERE RelationId IN :whoIds) AND Incoming = false AND IsDeleted = false ORDER BY MessageDate ALL ROWS

In particular, there is an undocumented limitation with querying the ToIds field on EmailMessage, where if over 500 IDs are returned in total across all returned records, this error is thrown.

Fortunately, ToIds wasn't actually needed in the query so it was an easy fix.

You must log in to answer this question.

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