开发者

Why am I getting this exception in GAE

开发者 https://www.devze.com 2023-01-07 22:56 出处:网络
I just tested and redeployed my application to a test instance, and it worked fine, then i changed the app id and redeployed to my production instance, and I get an indexing problem. How do I avoid th

I just tested and redeployed my application to a test instance, and it worked fine, then i changed the app id and redeployed to my production instance, and I get an indexing problem. How do I avoid this in the future? I went to the effort to test it first and it worked fine!

Uncaught exception from servlet
com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found..      <datastore-index kind="Article" ancestor="false" source="manual">
    <property name="tags" direction="asc"/>
    <property name="created" direction="asc"/>
</datastore-index>
at com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:40)开发者_StackOverflow中文版
at com.google.appengine.api.datastore.DatastoreApiHelper.makeSyncCall(DatastoreApiHelper.java:67)

The admin console says that it is "Building" the index. It has said that for 20 minutes now! How long does it take!?


When you create new queries, and use them for the first time on your local machine, they always work first time. When you run these new queries for the first time on google app engine, they will return this exception because the google app engine servers take some time to generate an "index" to allow your query to work properly.

I would recommend when you create new queries, to give them a once off run in the production environment to get the "index" built, so that when your users hit them, they work first time.

Secondly,manually pre defining your queries before you need them and uploading them to the server, means that when you really need them they may be built on the server already.


The way I work around this problem is to maintain a number of versions for my app. Typically something like this:

  • Version 1: Current Default
  • Version 2: Next release

When I have a new release ready for deployment, I upload it to version 2 in this instance. Once the indexes have been built I make version 2 the default. This way customers never experience any downtime or errors.

So in essence you could swap between version 1 and 2 when releasing a new version.

I would suggest that you do also pre-test within a different testing "Application" prior to uploading to your deployed "Application".


This happens because the app-engine Data Store Indexes are not initialized i.e. corydoras's answer is correct. I am adding my fix for java [I presume python and the index.yaml have a similar fix].

You can see which indexes are serving on your using your Google account on https://appengine.google.com/ . click the app link on the left and on the left menu choose Datastore Indexes under data

When one makes a new query to the datastore it can take hours for the data indexes to be updated.

First you should know that debugging in the local environment creates a file called datastore-indexes-auto-xml every time a new "Kind" of entity is stored.

In the local environment it can be used instantly for a query but there is a delay in updating the datastore-indexes-auto-xml.

When deploying an application to the appengine the auto generated datastore-indexes-auto-xml is submitted and the data indexes are updated much faster [to see the results refresh the page].

So

  1. Make sure none of your Entities have illegal signs e.g. '&'.
  2. Open the Data Indexes view on appengine.google.com.
  3. Make sure you havn't deleted the datastore-indexes-auto-xml. [I do this routinely]
  4. Store an Entity of each "Kind"!
  5. Use all the "Kinds" in Queries!
  6. Make sure the datastore-indexes-auto-xml is updated [I sometimes even restart eclipse]
  7. Deploy to appengine.
  8. Refresh Data Indexes view on the browser.
  9. Wait until you see the indexes

    Why am I getting this exception in GAE

  10. Please tell Google to fix this.
  11. This was informative but didn't work for me: enter link description here
  12. This was also informative but didn't work for me: enter link description here


Check your index.yaml file and make sure the proper indices are specified there, etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号