When making a REST API query call from a Java client I'm getting an INVALID_QUERY_LOCATOR error. I'm familiar with the limitation around 10 query locators in the same time and in my code I'm avoiding running more than 10 queries in parallel. However in some cases I'm still getting this error.
The following steps will reproduce this error consistently:
- Run 10 queries that will return partial results in rest API, e.g. "Select Id from Account Limit 2100". Only run the first part so all query locators are now open.
- Finish one of the queries by calling its nextRecordsURL until the results is done. This is supposed to release the query locator.
- Now run another query same as the above - it is expected to grab that query locator that was just released.
- Finish all other queries. You will fail on the first query that was started. The query from before "stole" its query locator and now we get INVALID_QUERY_LOCATOR
I've read the following articles but none of them seem to shed more light on this issue in this specific scenario: