+ Start a Discussion
dnakonidnakoni 

Too many cursors are in use

Did anyone received this error before? I tried to run batch apex throughout the day to test it and it was running ok and completing in around 20 mins. Now I tried scheduling it and just as it started running it failed with the following error:

 

"First error: Unable to access query cursor data; too many cursors are in use."

 

Any ideas?

 

 

forecast_is_cloudyforecast_is_cloudy

Per the Apex documentation,

"A user can have up to five query cursors open at a time. For example, if five cursors are open and a client application still
logged in as the same user attempts to open a new one, the oldest of the five cursors is released.
Note: Cursor limits for different Force.com features are tracked separately. For example, you can have five Apex
query cursors open, five batch cursors, and five Visualforce cursors at the same time."

 

For some reason, your class must be opening more than 5 cursors at the same time. I believe that each sub-query (for e.g. 'select id, (select id from Case) from Account') in a SOQL statement counts as a seperate cursor. You'll need to post your code to debug this further.

ShaoShao

Got this error message this morning as well, only one query in my batch job.

The job was running well in past 2 months.

But rerun is OK.

It might be a bug in Salesforce.