function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dl-knowledgedl-knowledge 

INVALID_QUERY_LOCATOR

I have developed an adapter for a third-party indexing engine that uses the sforce soap service as one of its data sources.  When I test the adapter outside of the indexing engine environement, as a standalone java app, I get all of my data.  However, when the indexing engine executes the adapter, I receive only the first set of data (1000 records).  When the source requests the second recordset, I receive an "INVALID_QUERY_LOCATOR" fault.  Anybody have any idea why?  Originally, the binding timeout was set to 0.  I have modified it to 300000, with no success.  Also, the adapter continues to function after that, querying the salesforce soap service for several other data types successfully.  I query for Accounts, which is where it fails, then Campaigns, Contacts, Events and Opportunities.  I modified the order of querying, and it failed when accessing the Contacts.  There are 43500 Account records.  There are 116,000+ Contact records.  Any help would be appreciated.
SuperfellSuperfell
You have to call queryMore at least every 15 minutes to keep your query cursor alive, it sounds like the processing is taking longer than that, so you cursor is getting cleaned up.
dl-knowledgedl-knowledge
So, then, the timeout is a service-side function?  Am I helpless to set it differently?  I have attempted to use SalesforceSoapBinding.setMaintainSession and SalesforceSoapBinding.setTimeout with no success.  I have also looked into modifying the queryResult size using _QueryOptions, per the API docs, but do not have a _QueryOptions object in my salesforce object hierarchy.  Do you have any suggestions?  My queryResult size is 1000, despite the docs listing the default size as both 500 and 2000.  Is there a phone number I can call to have a real-time discussion?  Thanks in advance.
SuperfellSuperfell
Correct, this is a server side clean, and you can't control the 15 minute window.

Depending on which exact soap stack & version your using it might be called _QueryOptions or QueryOptions.

The final batch size will depend on a number of factors include api version # used, QueryOptions header and the type and number of fields you selected.

You can call always call support and open a case.
dl-knowledgedl-knowledge
Thanks, Simon.  I found, via a Google search, a thread in the sforce developer boards that described another individual not having QueryOptions generated and followed the advice there.  Using a Type version of 1.2 and using the -a flag when using the AXIS2JAVA plug-in in eclipse, I was able to get a QueryOptions object.  I'll attempt to modify the batchSize to see if that fixes things.

However, in addition, I reviewed the logged output to determine how long it had been between the initial query and the queryMore call.  It was less than 1 minute.  :(  So, that must not be my problem.  Any other ideas?  I'll let you know if the batchSize has any affect.  And I'll call to open a case as well.

Thank you for your suggestions, though. 
SuperfellSuperfell
The other limit is that you can only have 5 active cursors per user, when the 6th cursor gets created the one that has the old last used time is deleted.
dl-knowledgedl-knowledge
How can I tell if I have too many active cursors?
SuperfellSuperfell
Don't you know how many your code is creating ?
dl-knowledgedl-knowledge
I believe it to be one.  However, since the solution is in the form of an adapter that is executed by a third-party  software application, I am uncertain.  I am continuing to search their documentation for execution information and viewing the log shows no indication of multi-threading.  I query five saleforce objects, sequentially: Accounts, Campaigns, Contacts, Events, and Opportunities.  Each object is queried without a filter and requests all fields.  I have modified the code, now, changing the batchSize from the default of 1000, to 200 and to 2000, none of which affects my situation;  The Account query still fails when attempting to get the second set of data, claiming an INVALID_QUERY_LOCATOR.
dl-knowledgedl-knowledge
SimonF, you still have not shared with me how it is I determine how many active cursors I have.
JesterJester
Everytime you make a query you have an active cursor.

So if you make five queries, you have 5 cursors.  On your sixth call, your first query is invalidated, because you already had 5 open.

Just like only you can prevent forrest fires, only you can determine your number of active cursors.


dl-knowledgedl-knowledge
Can active cursor counts mount if not closed properly or the session ends abruptly?  Is there a way to use the API to query for how many active cursors are open at a given moment?
SuperfellSuperfell
Every time you call query and the QueryResult includes a QueryLocator you created a query cursor.
Pedram SalehPedram Saleh
I know this thread is super old, but just in case anyone comes here while Googling the error, I also received this message because of a malformed query URL. I was missing the "?q=" after "query/")
Megha KaushikMegha Kaushik
This helped, thanks Pedram