BadRequestError: query not found (occurring in the middle of a for loop)

116 views
Skip to first unread message

Raj Arasu

unread,
Apr 8, 2011, 4:24:15 PM4/8/11
to Google App Engine
Hello,

I am currently having issues with the error BadRequestError: query not
found. I am using the django framework with norel. Here is the
context in which the error occurs:
1. query for all users -> People.objects.all()
2. loop through all these users and perform some action on them

Everything performs as expected up until the loop reaches the 101th
person. At this point I receive the above mentioned error. I tested
this through the remote shell and while it did work, I saw brief
moments of pause after each 100 people were looped through. For
example, there were pauses at 100, 200, 300 and so on. Also, to be
clear there are only 450 people in this datastore kind.

I not sure if there is a timeout issue, if GAE is querying in 100
record blocks...

If anyone can offer any insight that would be great.

Thanks,

Raj

Raj Arasu

unread,
Apr 11, 2011, 12:01:51 PM4/11/11
to Google App Engine
Here is the call stack when the error occured:

Exception in request:
Traceback (most recent call last):
File "/base/data/home/apps/5.349484817187351539/django/core/handlers/
base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/base/data/home/apps/5.349484817187351539/ftb/views.py", line
340, in send_sms_email
send_sms.load_store()
File "/base/data/home/apps/5.349484817187351539/sms.py", line 121,
in load_store
self.recipients()
File "/base/data/home/apps/5.349484817187351539/sms.py", line 62, in
recipients <---------------------------------------------------
for recipient in sms_recipients:
File "/base/data/home/apps/5.349484817187351539/django/db/models/
query.py", line 107, in _result_iter
self._fill_cache()
File "/base/data/home/apps/5.349484817187351539/django/db/models/
query.py", line 773, in _fill_cache
self._result_cache.append(self._iter.next())
File "/base/data/home/apps/5.349484817187351539/django/db/models/
query.py", line 275, in iterator
for row in compiler.results_iter():
File "/base/data/home/apps/5.349484817187351539/djangotoolbox/db/
basecompiler.py", line 218, in results_iter
for entity in self.build_query(fields).fetch(low_mark, high_mark):
File "/base/data/home/apps/5.349484817187351539/djangoappengine/db/
compiler.py", line 109, in fetch
for entity in results:
File "/base/python_runtime/python_lib/versions/1/google/appengine/
datastore/datastore_query.py", line 1240, in next
next_batch = self.__batcher.next()
File "/base/python_runtime/python_lib/versions/1/google/appengine/
datastore/datastore_query.py", line 1123, in next
return self.next_batch(1)
File "/base/python_runtime/python_lib/versions/1/google/appengine/
datastore/datastore_query.py", line 1149, in next_batch
batch = self.__next_batch.get_result()
File "/base/python_runtime/python_lib/versions/1/google/appengine/
api/apiproxy_stub_map.py", line 592, in get_result
return self.__get_result_hook(self)
File "/base/python_runtime/python_lib/versions/1/google/appengine/
datastore/datastore_query.py", line 1053, in __query_result_hook
self.__conn.check_rpc_success(rpc)
File "/base/python_runtime/python_lib/versions/1/google/appengine/
datastore/datastore_rpc.py", line 1048, in check_rpc_success
raise _ToDatastoreError(err)
BadRequestError: query not found

As you can see the exception occurs when executing the next iteration
of the FOR loop (not in the body). Also, this problem always occurs
after 100 iterations. Has anyone come across this error? There
doesn't seem to be much documentation online.

Rhys !

unread,
Jun 13, 2011, 12:11:44 AM6/13/11
to google-a...@googlegroups.com
I'm having a similar issue, but I only seem to get to 60 iterations. I've only had the problem once so that number might change.
Traceback (most recent call last):
  File "/base/data/home/apps/4-2dev.351074813615198448/cron.py", line 95, in get
    for key in WithoutMbidQuery:
  File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2313, in next
    next_batch = self.__batcher.next()
  File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2183, in next
    return self.next_batch(self.AT_LEAST_ONE)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2220, in next_batch
    batch = self.__next_batch.get_result()
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 592, in get_result
    return self.__get_result_hook(self)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_query.py", line 1970, in __query_result_hook
    self._conn.check_rpc_success(rpc)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1048, in check_rpc_success
    raise _ToDatastoreError(err)
BadRequestError: query not found
I've found a bug report that might be related, which I encourage everyone to star.

Daniel Upton

unread,
Jun 29, 2011, 1:04:23 PM6/29/11
to google-a...@googlegroups.com
I'm having the same issue.  Where are the google employees on this?

Alfred

unread,
Jul 6, 2011, 12:00:11 PM7/6/11
to google-a...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages